2

I have form in child components and i put child component under parent-component form. I have implemented canDeactivate which is not working for child component.

export const routes: Routes = [
  {path: '', component: AppComponent,children:[
  {path:'user/new',component:UserFormComponent,canDeactivate: [CanDeactivateGuard]},
  {path:'',component:UserListComponent}
]},
];

The following stackblitz example. Stackblitz exmaple for candeactivate

Can anyone help me, where i am doing wrong

Siddu hadapad
  • 3,023
  • 5
  • 15
  • 26
  • You're not getting to `UserFormComponent` `submit` function. Your submit button in `FirstChildComponent` is not doing anything – benshabatnoam Jan 09 '19 at 12:19
  • [Forked](https://stackblitz.com/edit/angular-so-54108211) your project to let you see that the `CadDeactivateGuard` is working. But I'm not sure what you're trying to do... – benshabatnoam Jan 09 '19 at 12:42

0 Answers0