How do I select a ContentChild of a native element in Angular 6?
问题 I have a component that uses content projection. <ng-content select="button"> </ng-content> I want to do something like this in my component: @ContentChild('button') button: ElementRef; However, when I check this.button , it is undefined both in ngAfterViewInit and ngAfterContentInit . How can I select my content child if it is a native element and not a custom component? 回答1: None of the query decorators can select native elements without a reference. @ViewChild('button') @ViewChildren(