RouterConfig的路径只接受1depth值?
我的意思是......这是不允许的?
{ path: 'service/band',}
export const appRoutes: RouterConfig = [
{
path: 'service/band',
component: EventDashboard
}
]
export const APP_ROUTER_PROVIDER = provideRouter(appRoutes);
http://localhost/service/band< - 不行! 访问失败。
VM73168:77 Error: Uncaught (in promise): Error: Cannot match any routes: 'band'
at resolvePromise (eval at 989 (polyfills.js:284), <anonymous>:538:32)
export const appRoutes: RouterConfig = [
{
path: 'serviceband',
component: EventDashboard
}
]
export const APP_ROUTER_PROVIDER = provideRouter(appRoutes);
http://localhost/serviceband&lt; - work!
angular2 rc3, angular2 Route-3.0.0.alpha8使用。
答案 0 :(得分:0)
这比你的例子稍微复杂一点,但从文档https://angular.io/docs/ts/latest/guide/router.html的路由器示例的plunker开始,我只是修改了&#34; /英雄&#34; app / heroes / hereoes.routes中的路由是&#34; / show / heroes&#34;并在app / app.component中修改了相关的routerLink。
export const HeroesRoutes: RouterConfig = [
{ path: 'show/heroes', component: HeroListComponent },
{ path: 'hero/:id', component: HeroDetailComponent }
];
然后
<a [routerLink]="['/show/heroes']">Heroes</a>
如果你看一下那个http://plnkr.co/edit/zzwJsKiYFD3VhjC3IdW7?p=preview,你会发现点击英雄链接就可以了。
您是否可以发布更多代码以帮助确定您的具体问题?
编辑:这可能只是您更改路线时未重建应用的简单情况。我已经在webpack中遇到过几次......