简体   繁体   English

在另一个组件的路由器出口中使用@Input显示组件

[英]Displaying component with @Input in another component's router-outlet

I wanted to know if you guys know a way to display components that take a @Input directive inside of a router-outlet. 我想知道你们是否知道一种显示在路由器出口内采用@Input指令的组件的方法。

I have several components that takes in @Inputs and I would like to display these components dynamically in one component. 我有几个使用@Inputs的组件,我想在一个组件中动态显示这些组件。 I would like to design this one component container to be as abstract as possible, so it would be reusable and extendable in the future. 我希望将这一组件容器设计为尽可能抽象,以便将来可以重用和扩展。

I'm trying to achieve something like 我正在努力实现类似

big-container.component has big-container.component具有

<router-outlet name='container1'></router-outlet>

in which links to container1.component which contains 在其中链接到container1.component,其中包含

<container1 [settings]=mySettings></container1>

I would like to get container1.component to display in big-container.component's router-outlet with the [settings]. 我想使用[settings]将container1.component显示在big-container.component的路由器出口中。

Thank you! 谢谢!

As this POST states it is currently not possible. 如该POST所述,当前是不可能的。

Here is the linked issue on Github 这是Github上的链接问题

Use a shared service to communicate with components added by the router. 使用共享服务与路由器添加的组件进行通信。 For details see https://angular.io/docs/ts/latest/cookbook/component-communication.html 有关详细信息,请参见https://angular.io/docs/ts/latest/cookbook/component-communication.html

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

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