I have a complexe module called MyPageModule
importing several modules which provides Service with following annotation @Injectable( { providedIn: 'root' } )
.
This module is imported by lazy loading like this:
// AppRoutingModule
...
{
path: 'my-page',
loadChildren: './lazy-loader-modules/lazy-loader-mypage/lazy-loader-mypage.module#LazyLoaderMyPageModule'
}
...
// LazyLoaderMyPageModule
@NgModule({
declarations: [],
imports: [
CommonModule,
MyPageModule
]
})
export class LazyLoaderMyPageModule { }
Behavior that I want (not the case actually): When url is different of /my-page/*, I'd like that all services imported by MyPageModule are destroyed.
How can I do this ?