Reputation: 11
I would like to create a deactivate guard that is trigerred only when navigating outside of child routes.
In rc4 ("@angular/router": "3.0.0-beta.1"
) this code was working as described:
path: '',
component: RootComponent,
canDeactivate: [CanDeactivateGuard],
children: [{
path: '',
component: XComponent,
}, {
path: 'somepath',
component: YComponent
}]
}
In this example navigating from XComponent
to YComponent
did not trigger deactivate guard, but for example navigating to "someNotChildComponent"
did.
After updating to @angular/route 3.0.0-rc.1
guard is triggered for every path change. What is correct behavior? Are there better ways to handle this case?
Upvotes: 1
Views: 395
Reputation: 825
I believe you can add the
canDeactivate: [CanDeactivateGuard]
inside your child routes definition instead of the parent route.
Upvotes: 0