angular-guards

Angular use modal dialog in canDeactivate Guard service for unsubmitted changes (Form dirty)

不想你离开。 提交于 2019-11-26 23:06:03
问题 In my Angular 4 application I have some components with a form, like this: export class MyComponent implements OnInit, FormComponent { form: FormGroup; ngOnInit() { this.form = new FormGroup({...}); } they use a Guard service to prevent unsubmitted changes to get lost, so if the user tries to change route before it will ask for a confirmation: import { CanDeactivate } from '@angular/router'; import { FormGroup } from '@angular/forms'; export interface FormComponent { form: FormGroup; } export