Just remove the # sign from your ViewChildren selector - that is used only in templates:@ViewChildren('fieldcmp') fieldsList: QueryList;或者你可以使用组件类作为选择器:Or you could use component class as a selector:@ViewChildren(HelloComponent) fieldsList: QueryList<HelloComponent>;在这里工作 stackblitz:https://stackblitz.com/edit/angular-xeudlpWorking stackblitz here: https://stackblitz.com/edit/angular-xeudlp 这篇关于Angular 6:获取对使用 *ngFor 在 ng-container 标签内创建的组件的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-15 19:40