[英]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.