简体   繁体   English

Angular 2,不渲染动态组件的子组件

[英]Angular 2, sub-components of dynamic component are not rendered

I'm using this method我正在使用这种方法

<ng-container
   *ngComponentOutlet="myComponent">
</ng-container>

to inject one component into another component, in my case a form into a sidebar.将一个组件注入另一个组件,在我的例子中是一个表单到侧边栏。 However from the injected component (the form) I cannot use pipes and shared components of the application.但是,从注入的组件(表单)中,我无法使用应用程序的管道和共享组件。 No component or pipe present in the shared.module is recognized within the injected component.在注入的组件中没有识别出 shared.module 中存在的组件或管道。 How can I make shared components available in the component injected through ngComponentOutlet?如何在通过 ngComponentOutlet 注入的组件中提供共享组件?

I did it, but : I did it using the component factory angular-comp-factory .我做到了,但是:我使用组件工厂angular-comp-factory做到了。 But actually I have another question: My component is getting rendered but without its sub-components.但实际上我还有另一个问题:我的组件正在渲染但没有其子组件。 How can I render its sub-components using the component factory?如何使用组件工厂渲染其子组件?

I managed.我管理。 It was only a problem with the arrangement of the modules.这只是模块排列的问题。

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

相关问题 使用动态子组件对组件进行反应 - React Component with dynamic Sub-Components 聚合物2.0:在Chrome的测试中未呈现的子组件 - Polymer 2.0: Sub-components not rendered in tests on Chrome 如何正确地将一个组件的代码拆分为多个子组件? - How to properly split the code of a component into sub-components? 棱角分明。 如何在外部定义点击,不包括子组件? - Angular. How to define a click outside, excluding sub-components? 使用Bulma和Angular 5创建选项卡并调用子组件 - Creating Tabs and calling sub-components with Bulma and Angular 5 Material UI如何使用整个组件的一种主要通用样式设置子组件的外部样式 - Material UI How to set external styles for sub-components with one main common style for the entire component 在使用Jest单元测试React组件时如何模拟子组件 - How to mock out sub-components when unit testing a React component with Jest 当React / Flux中有多个小的可重复子组件时,如何管理组件渲染 - How to manage component rendering when there are several small, repeatable sub-components in React/Flux 使用带有 props 的子组件动态反应 - React dynamically using sub-components with props 如何让react-table的第一个子组件默认打开并手动打开其他子组件 - How to make first sub-component of react-table open by default and open other sub-components manually
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM