【发布时间】:2022-12-21 04:33:37
【问题描述】:
我有这个模块联合工作区
apps
-- host
---- src
------ app
-------- app.component.ts
-- main
---- src
------ app
-------- app.component.ts
libs
-- components
---- menu
------ src
-------- lib
---------- menu.component.ts
-- services
---- src
------ lib
-------- global.service.ts
全球服务.ts
items$ = new BehaviorSubject<any[]>([]);
setMenuItems(items: any[]): void {
this.items$.next(buttons);
}
菜单.component.ts
items: any[];
ngOnInit(): void {
this.globalService.items$.subscribe((result) => {
this.items = result;
});
}
主机应用程序 - app.component.ts
ngOnInit(): void {
this.globalService.setMenuItems([1, 2, 3]); // this works
}
主应用程序 - app.component.ts
ngOnInit(): void {
this.globalService.setMenuItems([1, 2, 3]); // this not works
}
我无法在我的主应用程序中使用全球服务。
这是我用来运行项目的命令:nx serve host--devRemotes="main"
【问题讨论】:
标签: angular angular-module-federation