路由器插座工作不正确

router-outlet works incorrect

加载 Router 的组件在 router-outlet 外渲染 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) {}
}

控制台没有错误。在检查一个元素时,我看到 router-outlet 是空的,组件在它之后渲染。

这是设计使然。有一个相关的未解决问题 https://github.com/angular/angular/issues/8529,但我不认为这是考虑更改的内容。