[英]Angular 8 - How to dynamiclaly add children routes
I have a parent module, client-migration.module.ts that is being lazily loaded in app-routing.module.ts .我有一个父模块 client-migration.module.ts 正在延迟加载到 app-routing.module.ts 中。 In client-migration-routing.module.ts , I need to somehow load routes that are coming from a service.在 client-migration-routing.module.ts 中,我需要以某种方式加载来自服务的路由。 How can I achieve that?我怎样才能做到这一点?
According to your question I think what you need is Multiple Router Outlets so that you can dynamically load different components in different sections of your page.根据您的问题,我认为您需要的是多个路由器插座,以便您可以在页面的不同部分动态加载不同的组件。
Here one is primary outlet and second is named outlet这里一个是主要出口,第二个是命名出口
<router-outlet></router-outlet>
<router-outlet name="sidebar"></router-outlet>
In your routing.module.ts you can add route like this.在您的 routing.module.ts 中,您可以像这样添加路由。
{
path: "",
component: SidebarComponent,
outlet: "sidebar"
}
You can call the service no problem in that.您可以调用该服务没问题。
That's it you are good to go, here is the reference Link就是这样你很高兴,这是参考 链接
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.