Skip to content

Commit

Permalink
Implementing guard preventing loss data
Browse files Browse the repository at this point in the history
Save change on edit profile.
  • Loading branch information
Oktawian-L committed Nov 3, 2019
1 parent 58e7b99 commit 4d15e31
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Subiton/src/app/_guards/prevent-unsaved-changes.guard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { CanDeactivate } from '@angular/router';
import { UserEditComponent } from '../users/user-edit/user-edit.component';

export class PreventUnsavedChanges implements CanDeactivate<UserEditComponent> {

canDeactivate(component: UserEditComponent) {
if (component.editForm.dirty) {
return confirm('You have unsaved changes. Are you sure?');
}
return true;
}

}

0 comments on commit 4d15e31

Please sign in to comment.