My code:
const routes: Routes = [{
path: '',
component: HomeComponent,
children: [
{
path: '',
component: ComponentOne,
outlet: 'homeMainContent',
pathMatch: 'full'
},]},
{
path: 'list',
component: ListComponent,
outlet: 'homeMainContent',
},
{
path: 'auth',
loadChildren: 'app/auth/auth.module#AuthModule'
}, {
path: 'admin',
loadChildren: 'app/admin/admin.module#AdminModule'
}];
When I access the list component the url resolves correctly but the html template doesn't change.
If I put the ComponentOne and ListComponent routes in the same child array like this:
const routes: Routes = [{
path: '',
component: HomeComponent,
children: [
{
path: '',
component: ComponentOne,
outlet: 'homeMainContent',
pathMatch: 'full'
},
{
path: 'list',
component: ListComponent,
outlet: 'homeMainContent',
},]},
I get an error
error: cannot match any routes.
How do I solve this:
- For the template to load with the corresponding url?
- And how to avoid the error(if possible) when I put the ComponentOne and ListComponent routes in the same child array?
I have seen a couple of answers including this answer but they don't solve my problem.
Update: This is my HomeComponent code
<div class="body">
<div class="box">
<div class="one"><home-left-content></home-left-content></div>
<div class="two"><home-main-content></home-main-content></div>
<div class="three"><home-right-content></home-right-content></div>
</div>
</div>
and my home-main-content component code looks like this:
<div>
<router-outlet name="homeMainContent"></router-outlet>
</div>
This same setup works in my admin-routing configuration file. That is why I am confused when I get the errors. I was wondering maybe it is because I have an empty sting as the path or because the homecomponent code exists in the main routing config file?