I recently started a new project based on angular 2.0.0 in combination with Angular Router (V3.0.0). Thereby I have issues with the auxiliary routes.
I want to split up my application in different views that appear in every state like navigation bar, main content, footer etc. So that when the user interact with the site only the part of the page that needs to be changed (f.e. the content) is changed and all other views are left as they are.
Therefore I wanted to use the routers auxiliary feature as discussed in this talk:
Angular Router Talk @AC2015
I set up my files as follows:
app.html
<router-outlet name="navigation"></router-outlet>
<main>
<router-outlet></router-outlet>
</main>
<router-outlet name="footer"></router-outlet>
app.routes.ts
import {Routes} from '@angular/router';
export const rootRouterConfig: Routes = [
{path: '', redirectTo: 'start(navigation:/navigation)', pathMatch: 'full'}
];
start.routes.ts
import {Routes} from '@angular/router';
import {StartContentComponent} from './startContent/startContent.component';
import {StartNavigationComponent} from "./startNavigation/startNavigation.component";
export const startRouterConfig: Routes = [
{path: 'start', component: StartContentComponent},
{path: 'navigation', component: StartNavigationComponent, outlet: 'navigation'}
];
Now the problem is: If I manually enter
http://localhost:3000/#/start(navigation:/navigation)
into the url of the browser both components are displayed correctly. But the redirect in app.routes.ts is not working and I get the following error when accessing http://localhost:3000/#/:
Uncaught (in promise): Error: Cannot match any routes: ''
The official Angular 2 docs say nothing about auxiliary routing yet only that it will be discussed in the future. Apart from that I found some other blogposts but none of them discussed auxiliary routes in combination with redirects.
Does anyone know what my problem is or have similar issues?
Is there another approach to structure my page to achieve what I want?
Should I maybe switch to Ui-router?
See Question&Answers more detail:
os