问题
i have serious problem with angular 2 (RC1) router.
This code works:
<a [routerLink]="['/anythingEvenNotExistingRoute']"></a>
<router-outlet></router-outlet>
This doesn't:
//<a [routerLink]="['/anything']"></a> <-- without this line in html template
<router-outlet></router-outlet>
...so it looks like angular router needs atleast one routerLink in html template.. thats pretty strange..
回答1:
This is currently a bug present in the Angular 2 RC Router https://github.com/angular/angular/issues/8409.
As mentioned in the GitHub issue, to get around it you can either inject the router into AppComponent or just put an empty router link (<a [routerLink]="['/']"></a>) into your template.
来源:https://stackoverflow.com/questions/37310539/angular-2-rc1-router-doesnt-work-without-any-routerlink