在angular2组件中使用transclusion时,看起来我的'ViewChildren'无法检测到这些组件。当我制作一个组件时,我直接定义了相同的组件,然后它可以正常工作。现在有人有办法得到这个工作吗?Angular2 ViewChildren与transclusion结合使用
1
A
回答
2
您可以使用@ContentChild()
或@ContentChildren()
查询transcluded内容。
@ViewChild()
和'@ ViewChildren()`只允许查询组件模板中的元素。
现在还angular 2/typescript : get hold of an element in the template
0
我试图用我的错误消息组件做到这一点。其实你只需要用ContentChildren
修饰器代替ViewChildren
。它适用于ng内容元素。因此,您将获得QueryList
,这是您的组件或元素的可迭代对象。
相关问题
- 1. Transclusion(真) - 结合值
- 2. 如何在Angular2中使用@ViewChildren?
- 3. 如何结合transclusion,replace和ngIf?
- 4. Angular2中的ViewChildren装饰器可以使用接口吗?
- 5. 如何在Angular2中测试transclusion(ng-content)?
- 6. 整合angular2与
- 7. 异步结合angular2
- 8. ViewChildren为NG-模板
- 9. 嵌套指令与transclusion
- 10. Angular2与NodeJs合作
- 11. 角Transclusion
- 12. angular2 onError的图像结合
- 13. ob_start()与wp_query结合使用
- 14. 结合使用mime_content_type与ACF
- 15. 与Monotouch结合使用PonyDebugger?
- 16. Flot与Zepto结合使用
- 17. PHPExcel:结合使用“getHighestRow”与
- 18. 结合使用str_replace与ut8_decode
- 19. Html.Raw()与Razor结合使用?
- 20. 使用Bridget.NET与Angular2
- 21. Angular2 @ViewChildren在其他组件中返回undefined
- 22. ViewChildren不ngFor
- 23. 使用holoeverywhere与actionBarSherlock结合使用
- 24. 使用ng-content与多个选择器的Dart Angular 2 Transclusion
- 25. 如何整合Angular2与Java
- 26. 当与node.js服务器结合使用时,Angular2英雄示例双倍POST
- 27. 如何在angularjs中使用transclusion?
- 28. DI和transclusion
- 29. Mediawiki Multilevel Transclusion
- 30. MediaWiki 1.16:Section transclusion
见仅供参考,我们使用术语*内容投影*而不是transclusion。 – drewmoore
感谢这个不错的加法! –