简体   繁体   English

使用 ngForOF 指令创建 TemplateRef 类型的 QueryList

[英]Creating QueryList of type TemplateRef using ngForOF directive

Assuming @ContentChildren is used in component A , targeting QueryList<TemplateRef> .假设@ContentChildren在组件A中使用,针对QueryList<TemplateRef>

Is it possible for component B to use component A in its template, passing it as a single TemplateRef on which we iterate over using NgForOf directive, simply creating QueryList of type NgTemplate without rendering it, just as we would pass it multiple items of type NgTemplate ?组件B是否可以在其模板中使用组件A ,将其作为单个TemplateRef传递,我们使用NgForOf指令对其进行迭代,只需创建QueryList类型的NgTemplate而不渲染它,就像我们将多个NgTemplate类型的项目传递给它一样?

Using the regular *ngFor syntax work perfectly:使用常规的*ngFor语法可以完美地工作:

<ng-template *ngFor="let action of actions">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM