我想在 Router 和 RouterModule 之外创建具有视图层次结构的组件
例子:
比较父.ts
@Component({
selector: 'comp-parent',
template: `
<p>parent works</p>
<router-outlet></router-outlet>
`,
styleUrls: ['./comp-parent.css']
})
export class ComponentParent {
protected foo: string;
}
comp-children.ts
@Component({
selector: 'comp-children',
template: "<p>Children works</p>",
styleUrls: ['./comp-children.css']
})
export class ComponentChildren extends ComponentParent { }
组件-foo-bar.ts
@Component({
selector: 'component-foo-bar',
template: "<comp-children></comp-children>",
styleUrls: ['./component-bar.css']
})
export class ComponentFooBar { }
我ComponentBar
希望这comp-children
将comp-parent
包含comp-children
在内,但仅comp-children
加载模板。
如何加载<router-outlet/>
已解析为模板的父comp-children
模板?