Angular use modal dialog in canDeactivate Guard service for unsubmitted changes (Form dirty)
- 阅读更多 关于 Angular use modal dialog in canDeactivate Guard service for unsubmitted changes (Form dirty)
问题 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