Reputation: 6406
edit it works when removing the "name" from my nested outlet AND removing the "outlet" property from the routes module. Is it mandatory to have an unnamed outlet before using named ones?
The following RouterMOdule config is in place:
const appRoutes: Routes = [
// Public area: login (default)
{ path: '', component: LandingPageComponent,
canActivate: [AuthAutoRedirectService],
children: [
{ path: '', outlet: 'active-box', component: LoginComponent }
]
},
// Secure area
{ path: 'secure', component: SecureAreaComponent,
canActivate: [AuthGuardService],
data: { roles: ['user'] },
children: [
// Dashboard (default)
{ path: '', outlet: 'main-content', component: DashboardComponent },
// Resolutions
{ path: 'resolutions', outlet: 'main-content', component: ResolutionsComponent },
// Documents
{ path: 'documents', outlet: 'main-content', component: DocumentsComponent },
]
},
];
@NgModule({
imports:[
RouterModule.forRoot(appRoutes)
],
exports:[
RouterModule // configured router module
]
})
router-outlet
: displays the logon page OR the secure area whereabouts
| - router-outlet name="main-content"
displays the selected page in the secure area
localhost:4200/
properly serves the login pagelocalhost:4200/secure
properly serves the secure area, showing the "dashboard" as main pagethe problem arises when trying to access an other child of the secure area:
core.es5.js:1020 ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'secure/documents'
Error: Cannot match any routes. URL Segment: 'secure/documents'
What could be the cause?
Thanks...
Upvotes: 0
Views: 739
Reputation: 6406
Ok, this explains that: https://github.com/angular/angular/issues/14830
You must have the outlet with the name primary on a template (if you don't specify the name it will be primary by default). Named outlets are auxiliary.
Outlet with name is an "auxiliary" outlet. Needs at least a "primary" (aka "unnamed") outlet.
Upvotes: 0