简体   繁体   English

动态 Angular 组件中的内容投影

[英]Content projection in dynamic Angular components

Is there a way to use content projection in dynamically loaded & created Angular 2 components?有没有办法在动态加载和创建的 Angular 2 组件中使用内容投影? By dynamic loading & creation i mean components aren't known at compilation time, they will be loaded & compiled & instantiated in run time.通过动态加载和创建,我的意思是组件在编译时是未知的,它们将在运行时加载、编译和实例化。

You pass them as projectableNodes to ViewContainerRef.createComponent()您将它们作为projectableNodes传递给ViewContainerRef.createComponent()

https://angular.io/docs/ts/latest/api/core/index/ViewContainerRef-class.html#!#createComponent-anchor https://angular.io/docs/ts/latest/api/core/index/ViewContainerRef-class.html#!#createComponent-anchor

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

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