Am trying to navigate my Angular application based on parent child concept. When am loading the parent component gets loaded instead of the child but the url seems the
const appRoute: Routes = [
{ path: 'home', component: HomeComponent },
{ path: 'dashboard', component: DashboardComponent },
{
path: 'solutions', component: SolutionComponent,
children: [
{ path: 'cog', component: CogComponent }
]
},
{ path: 'portfolio', component: PortfolioComponent },
{ path: '**', component: PortfolioComponent }
];
When I run solutions/cog
it redirects to SolutionComponent
but it should load CogComponent
EDIT: 1
It will work when I use
const appRoute: Routes = [
{ path: 'home', component: HomeComponent },
{ path: 'dashboard', component: DashboardComponent },
{ path: 'solutions', component: SolutionComponent },
{ path: 'solutions/cog', component: CogComponent },
{ path: 'portfolio', component: PortfolioComponent },
{ path: '**', component: PortfolioComponent }
];
But I want it should load from above method.
Please help to solve this issue.
SolutionComponent
. It is working as expected. The way you've configured the routes,SolutionComponent
should have a<router-outlet>
in the HTML. Then, if you navigate tosolutions/cog
, it will show theSolutionComponent
and theCogComponent
in place ofrouter-outlet
. – Kassa