简体   繁体   English

在角度6中,我们可以在两个ng元素之间共享路线对象吗?

[英]In angular 6, can we share routes object between two ng elements?

We want to build header as angular elements and create a separate build so that can be accessible with multiple angular apps. 我们希望将标头构建为有角度的元素,并创建一个单独的构建,以便可以使用多个有角度的应用程序进行访问。

But issue is that routes are defined in home app and when clicked from header it gives undefined error as it is separate ng app. 但是问题在于路由是在家庭应用中定义的,并且从标题中单击时会给出未定义的错误,因为它是单独的ng应用。

Is there some way to share or pass routes object to header from the home app? 有什么方法可以共享或将路由对象从家庭应用程序传递到标头?

That's the whole purpose of NgModules ... 这就是NgModules的全部目的...

@NgModule({
  imports: [RouterModule.forRoot(myRoutes)],
  exports: [RouterModule],
})
export class RoutingModule {}
@NgModule({
  imports: [RoutingModule],
  exports: [],
})
export class FirstApplicationModule{}
@NgModule({
  imports: [RoutingModule],
  exports: [],
})
export class SecondApplicationModule {}

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

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