我创建了一个带有选定
PYB按钮组
使用
@ViewChildren
,声明如下:
@ViewChildren('header', { read: ElementRef }) headers: QueryList<ElementRef>
我的HTML模板看起来有点像这样:
<div class="container" *ngIf="categories">
<div class="row" pyb-button-group>
<div class="col-md-4 col-6" *ngFor="let category of categories">
<a class="btn-choice" [routerLink]="['/' + category.id]">
<div class="header" #header>
<span class="title">{{ category.name }}</span>
</div>
</a>
</div>
</div>
</div>
所以我有一个方法
ngAfterViewInit
这样地:
ngAfterViewInit() {
console.log(this.headers);
}
它又回来了
undefined
…
我做错什么了吗?