I want to navigate a child root but after 1 navigation the url changing but the component is not load, but if I refresh the url the component is loading. If I am in the navigated root, url change but not load, if I am not on the navigated root it is loading.
the links..
http://localhost:4000/project-details/16/project-details
http://localhost:4000/project-details/21/project-details
//when select an option navigate to project-details/id
goToProjectDetails(projectId: any) {
this.router.navigate(['project-details', projectId]);
}
project-details.component
ngOnInit() {
this.subscription = this.route.params.subscribe(() => {
this.getProject();
this.tableRender();
});
}
app.routers.ts
{
path: "project-details/:id",
children: [
{
path:'',
redirectTo: 'project-details',
pathMatch: 'full'
},
{ path: 'project-details', component: ProjectDetailsComponent },
{ path: 'translation', component: TranslationComponent },
{ path: 'env', component: EnvVariablesComponent },
{ path: 'urls', component: UrlsComponent },
]
,
component: ProjectDetailsMenuComponent,
data: {
id: "project.details",
}
...
I found a solution:
//private state: StateService
ngOnInit() {
this.subscription = this.state.subscribeImmediately(() => {
this.getProject();
this.tableRender();
});
}