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?