Can you check the existence of an instance of a component from the component itself ?
Can you destroy existing instance and create a new instance ?
I seem to have a problem with one of my components. When visited multiple times consecutively with different params component's ngAfterViewInit fires only first time (i assume when the component was instantaited). Subsequent visits doesnt cause to fire ngAfterViewInit, ie, looks as if it is reusing the same component instance or something... however, I can identify the params and do the needful with the changed params..
However, If I visit a new route and come back to the route/compoent in question it works normal. and I can see it is getting destroyed before the new route and corresponding component initiated.
My objective is to re-instatiate the component EVERY TIME I vist the route.
So
Can you check the existence of an instance of a component from the component itself ?
Can you destroy existing instance from code and create a new instance ?
Or is there any other way to tackle this issue.
My setup
Lazy loaded module -> mdm
const routes: Routes = [
{
path: '',
component: HomeComponent,
children : [
{ path: ':id' , component : AComponent }
]
}
Menu AnchorLinks
- mdm/1000
- mdm/2000 etc etc