加载路由器的组件正在路由器外部呈现 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) {}
}
控制台没有错误。在检查元素时,我看到路由器出口是空的,组件在它之后呈现。
答案 0 :(得分:3)
这是设计的。有一个相关的公开问题https://github.com/angular/angular/issues/8529,但我没有得到这样的印象,即考虑进行更改。