简体   繁体   English

Angular 6-自定义模态窗口内的嵌套组件

[英]Angular 6 - Nested Components inside Custom Modal Window

I followed this post to create a custom modal. 我按照这篇文章创建了一个自定义模式。 Everything works as supposed except putting other Angular components inside the <div class="modal-body"> . 除了将其他Angular组件放入<div class="modal-body">之外,其他所有操作均按预期进行。

The template and CSS of the inserted components loads but the javascript just doesn't work. 加载的组件的模板和CSS已加载,但javascript无效。

How is it possible to insert working Angular components into such a dialog? 如何在这样的对话框中插入可用的Angular组件?

for all the dynamically called components( those components which we are not mentioned in the template by the template selector) should be added to the entry components. 对于所有动态调用的组件(模板选择器未在模板中提及的那些组件)应添加到输入组件中。 If we do that Angular will instantiate the component for us. 如果我们这样做,Angular将为我们实例化该组件。

The best practice is to mention the components in the component declarations and if there is any dynamically created components, add them into entry components. 最佳实践是在组件声明中提及组件,如果有任何动态创建的组件,请将其添加到条目组件中。 Everytime we add components to entry components it cost us the performance. 每次我们将组件添加到入门组件时,都会降低性能。 try to reduced the entry components :). 尝试减少入口组件:)。 Hope I answered your query. 希望我回答了您的查询。

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

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