Angular 4-模板继承 [英] Angular 4 - Template inheritance
本文介绍了Angular 4-模板继承的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下子组件,它是继承父组件:
I have the following child component and it's inheritance parent component:
@Component({
template: `<p>child</p>`
})
export class EditChildComponent extends EditViewComponent{
constructor(){
super();
}
}
@Component({
template: `<p>parent</p>`
})
export class EditViewComponent{
constructor(){
}
}
现在有什么方法可以像在嵌套组件中使用ng-content一样将EditViewComponent的模板放置在ChildComponents模板中吗?我将如何获得以下结果:
Now is there any way to place the template of the EditViewComponent in the ChildComponents template like you would do with ng-content in nested components? How would I get the following result:
<p>parent</p>
<p>child</p>
推荐答案
当前为Angular不提供此功能. 但是,您可以使用"Narik"在angular中应用"UI继承".
Currently Angular Doesn't provide this feature. But you can use "Narik" to apply "UI Inheritance" in angular.
https://docs.narik.me/04.-ui-inheritance
这篇关于Angular 4-模板继承的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文