My code is as follows :
app component html
<app-header ></app-header>
<router-outlet></router-outlet>
<app-footer></app-footer>
And routing.module.ts is
const routes: Routes = [
{ path: '', redirectTo: '/login', pathMatch: 'full'},
{ path: 'login', component: LoginPage, pathMatch: 'full' },
{ path: 'dashboard', loadChildren : './main.module#MainModule' } // lazy load post login success
];
export const appRouter: ModuleWithProviders = RouterModule.forRoot(routes, { enableTracing: true });
Below is my main.componnt.html
<div class="container-fluid">
<div class="row">
<nav class="col-md-2">
<router-outlet name="nav"></router-outlet>
</nav>
<section class="col-md-4">
<router-outlet name="list"></router-outlet>
</section>
<section class="col-md-6">
<router-outlet name="form"></router-outlet>
</section>
</div>
</div>
Below is main.module.ts
const childRoutes: Routes = [
{ path: '', component: SideNav, outlet: 'nav' }, // working
{ path: '', component: BlankComponent, outlet: 'form' },// working
{ path: '', component: BlankComponent, outlet: 'list' },// working
{ path: 'someform', component: SomeForm, outlet: 'form' },// issue
{ path: 'somelist', component: SomeList, outlet: 'list' },// issue
{ path: '**', component: PageNotFound, outlet: 'list' },
];
const mainRoutes: Routes = [
{ path: '', component: MainComponent, children: childRoutes }// works
];
export const mainRouter : ModuleWithProviders = RouterModule.forChild(mainRoutes);
I get below error
Error: Cannot match any routes. URL Segment: 'someform'
Where my router link is
[routerLink]="[navObj.url]"
where url contain "someform"
or "./somelist"
blank path components loading correctly but with path I am facing issue.
is router-outlet
inside another components router outlet supported in Angular 4?
What is the correct to implement above? I will add authGuard
later.
routerLink
to[{ outlets: { list: ['somelist'] } }]
but now its not able finddashboard
route – Anup B