我有三个组件
1) item(html)
<div>
<ng-content></ng-content>
</div>
2) list-container(html)
<ng-content></ng-content>
列表容器(TS)
@ContentChildren(forwardRef(() => Item), { descendants: true }) Items: QueryList<Item>;
ngAfterContentInit(): void {
console.log(this.Items); // issue is here. query List is empty
// how to access items
}
3)容器(html)
<container-list>
<ng-content></ng-content>
</container-list>
app.html中的
<container>
<item *ngFor="let item of items">{{item.name}}</item>
</container>