diff --git a/Subiton/src/app/_guards/prevent-unsaved-changes.guard.ts b/Subiton/src/app/_guards/prevent-unsaved-changes.guard.ts new file mode 100644 index 0000000..d04b300 --- /dev/null +++ b/Subiton/src/app/_guards/prevent-unsaved-changes.guard.ts @@ -0,0 +1,13 @@ +import { CanDeactivate } from '@angular/router'; +import { UserEditComponent } from '../users/user-edit/user-edit.component'; + +export class PreventUnsavedChanges implements CanDeactivate { + + canDeactivate(component: UserEditComponent) { + if (component.editForm.dirty) { + return confirm('You have unsaved changes. Are you sure?'); + } + return true; + } + +}