【发布时间】:2018-11-17 22:55:09
【问题描述】:
Anular 5:为了清晰的模块结构,我想制作一些 AbstractParentComponent(具有可重用的逻辑和模板)并有可能扩展它:
@Component({
selector: 'app-parent',
template: ' //reusable header element with logic
*here we should have ability to change part of tamplate*
<ng-container *ngTemplateOutlet="customTemplate"> </ng-container>
//reusable footer element with logic
'
})
export class ParentComponent{
//logic impl
并且我希望能够创建扩展所有父逻辑但使用自定义模板实现自己的部分的扩展组件:
@Component({
selector: 'app-child',
template: '
//here i wanna extend parent template
/*something like*/ <ng-template #customTemplate>
//some template impl
</ng-template>'
})
export class ChildComponent extends ParentComponent{}
怎么可能?
【问题讨论】:
-
尝试使用@ViewChild('changediv') changediv: TemplateRef
;但没有成功 -
你解决了吗?
-
不幸的是,没有。我通过其他方式没有扩展,但假设可以使用
和 @ViewChild
标签: html angular typescript components angular5