我正在尝试创建一个简单的嵌套路由器.这种结构在beta版本中有效,但随着候选路由器的推出,我发现自己陷入困境.
http://plnkr.co/edit/nn7KSJpqWuBpkxi1E6tJ
上面的plunkr是我的场景的一个人为的版本.尽管有
@Routes([
new Route({ path: '/applications/...', component: ApplicationRouter })
])
Run Code Online (Sandbox Code Playgroud)
路由器似乎没有识别非终端路由.
Error: Uncaught (in promise): Cannot match any routes. Current segment: 'applications'. Available routes: ['/applications/...'].
Run Code Online (Sandbox Code Playgroud) 我正在试验Angular 2并遇到了一个我不确定如何调试的问题.
示例情况
我有一个AppComponent处理所有基本级别路由,并且每个"级别"的路由下来都在该级别的新路由器上声明.
我有以下路线:
AppComponentAppComponentApplicationRouterComponentApplicationRouterComponent作为周围模板的一部分,有一个导航栏对所有页面都是通用的,因此需要能够链接到子路由器中定义的任何路由.[routerLink]嵌套组件不会导致任何错误抛出.
问题
当链接到孙子路由时,看起来View组件甚至不构造.即
<a [routerLink]="['./ApplicationRouter/New']">New Application</a>
将ApplicationRouterComponent被构建并显示,但NewApplication分量却没有.
代码示例
appComponent.ts
import {Component} from 'angular2/core';
import {
RouteConfig,
ROUTER_DIRECTIVES,
ROUTER_PROVIDERS
} from 'angular2/router';
import {ApplicationRouterComponent} from './routes/application/applicationRouter';
import {HomeComponent} from './routes/home/homeComponent';
@Component({
selector: 'bop-application',
templateUrl: 'app/index.html',
directives: [ROUTER_DIRECTIVES],
providers: [ROUTER_PROVIDERS],
})
@RouteConfig([
{ path: '/home', name: 'Home', component: HomeComponent, useAsDefault: true },
{ path: '/applications/...', name: 'ApplicationRouter', component: …Run Code Online (Sandbox Code Playgroud)