I have an Angular2 application with this route:
{
path: '',
component: ContentComponent,
children: [
{
path: 'folder/:folderId',
resolve: {
currentFolder: CurrentFolderResolver,
},
children: [
{
path: '',
resolve: {
folderStructure: FolderStructureResolve,
},
component: FolderOverviewComponent,
},
{
path: 'users',
component: UsersComponent,
}
]
}
]
}
When navigating from a route, for example / folder / 123 to / folder / 456, Angular will not start ngOnDestroy()at FolderOverviewComponent. Navigation in / folder / 456 / users will be performed.
In other words, it seems that Angular does not destroy the component if the route does not change (ignoring the dynamic part: folderId). This seems reasonable, however I need to clean things up ngOnDestroy().
Can I configure routes for destruction every time I switch to a new route (i.e. with a different parameter)?
source
share