I am trying to navigate from a component to another but i got this problem :Invalid configuration of route ”: redirectTo and children cannot be used together. How can i fix it please?
route file :
{ path: '', redirectTo: 'offre-management', pathMatch: 'full', children: [ { path: 'offre-mngmnt-sites-list-all', component: OffreMngmntSitesListAllComponent } ] }
html file when i am invoking method to navigate to the OffreMngmntSitesListAllComponent component:
<span role="button" (click)="showAll()"> show all </span>
and the ts file of when i have the method that will call the OffreMngmntSitesListAllComponent component:
showAll(){ this.router.navigate(["offre-mngmnt-sites-list-all"]) }
Advertisement
Answer
If OffreMngmntSitesListAllComponent
is really your child component then your routes should be like this:
const routes = { path: 'offre-management', component: ${your office management component}, children: [ { path: 'offre-mngmnt-sites-list-all', component: OffreMngmntSitesListAllComponent }, { path: '', redirectTo: 'offre-management', pathMatch: 'full', } ] };
And your navigation would be like:
this.router.navigate(["offre-management/offre-mngmnt-sites-list-all"])