我在角度 2 中遇到了基于">选择器"名称的负载组件的问题。
我想在我的弹出窗口中动态渲染组件。像这样的东西——这是代码:
<div>
<my-selector></my-selector>
</div>
我想在div 中渲染组件。
关于上面评论中提到的问题和 plunker。为了使您的选择器工作,您只需像这样在AppModule中添加组件即可。
declarations: [ App, PopupComponent, DynamicComponent ]
在此处添加组件后,可以在应用程序模板中根据需要使用选择器,如下所示:
<button (click)="openPopup()">Launch demo modal</button>
<hr>
<div>
<my-selector></my-selector>
</div>
<pre>{{closeResult}}</pre>