【发布时间】:2023-03-05 07:12:01
【问题描述】:
我有一个使用内容投影的组件。
<ng-content select="button">
</ng-content>
我想在我的组件中做这样的事情:
@ContentChild('button') button: ElementRef;
但是,当我检查this.button 时,undefined 在ngAfterViewInit 和ngAfterContentInit 中都是ngAfterContentInit。
如果我的内容子元素是原生元素而不是自定义组件,我该如何选择它?
【问题讨论】:
标签: angular angular6 angular-directive angular-template