I am having a hard time getting auxiliary routes to work, even in a minimalistic scenario. I'm pretty sure, I stuck to the angular documentation on routes and multiple outlets down to a T, so I really have no idea what I am missing.
app.routing.ts:
const appRoutes: Routes = [
{
path: '',
children: [
// aux route with named outlet, **DOES NTO WORK :(**
{
path: 'simple',
component: SimpleComponent,
outlet: 'simpleOutlet'
},
// default route, *WORKS*
{
path: '',
component: AppComponent
},
// fallback route, *WORKS*
{
path: '**',
component: AppComponent,
redirectTo: ''
}
]
}
];
app.component.html:
<h2>I am the app component</h2>
<router-outlet></router-outlet>
<router-outlet name="simpleOutlet"></router-outlet>
Before using routerLink
, I wanted to get it to work by entering a URL right into the browser. Is it possible, that I missed something crucial regarding navigating to aux routes by direct URL?
Here's what happens when directly hacking in URLS:
http://localhost:4200/
works;app.component.html
is displayedhttp://localhost:4200/somethingfallback123
works; due to the fallback-route,app.component.html
is displayedhttp://localhost:4200/(simpleOutlet:simple)
does not work neither doeshttp://localhost:4200(simpleOutlet:simple)
,http://localhost:4200/(simpleOutlet:/simple)
,http://localhost:4200/(simpleOutlet:simple/)
etc.. (you can see, I am desperate)
ERROR LOGS:
Mozilla Firefox:
ERROR Error: "[object Object]"
resolvePromise http://localhost:4200/polyfills.js:7882:31
resolvePromise http://localhost:4200/polyfills.js:7839:17
scheduleResolveOrReject http://localhost:4200/polyfills.js:7941:17
invokeTask http://localhost:4200/polyfills.js:7489:17
onInvokeTask http://localhost:4200/vendor.js:70021:24
invokeTask http://localhost:4200/polyfills.js:7488:17
runTask http://localhost:4200/polyfills.js:7256:28
drainMicroTaskQueue http://localhost:4200/polyfills.js:7663:25
It seems to be a know issue that Firefox does not throw correct error messages.
Google Chrome:
ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'simple'
Error: Cannot match any routes. URL Segment: 'simple'
Environment (angular version: ng v)
Angular CLI: 7.0.4
Node: 9.7.1
OS: linux x64
Angular: 7.0.2