加载路由器的组件正在路由器出口 app.component.ts 之外呈现
@Component({
selector : "body",
template : `<router-outlet></router-outlet>`,
directives: [ROUTER_DIRECTIVES]
})
@RouteConfig([
{path: "/auth/login", name: "Auth", component: AuthComponent},
{path: "/...", name: "Default", component: DefaultComponent}
])
export class AppComponent {
constructor(private _router: Router) {
}
}
default.component.ts
@Component({
template : `
<header-view></header-view>
<router-outlet></router-outlet>
`,
directives: [HeaderComponent, ROUTER_DIRECTIVES]
})
@RouteConfig([
{path: "/", name: "LevelsList", component: LevelListComponent, useAsDefault: true}
])
export class DefaultComponent {
constructor(private _router: Router) {}
}
控制台没有错误。在检查一个元素时,我看到路由器插座是空的,并且组件在它之后呈现。