将Angular应用程序中的服务注入自定义元素

问题描述

我目前正在根据以下原则开发Angular应用程序:

之所以选择这种设计,是因为我想要一个包含通用服务和使用这些通用服务的侧微应用程序(分别设计,构建和管理)的全局应用程序。

我有问题,需要帮助:

  • 根据我所说的,我想将主要的角度应用程序的服务共享到微型应用程序中。
  • 我可以使用输入装饰器(例如:@Input('logService'))与我的微应用共享服务,但这并不方便,因为我需要与共享服务一样多的输入,并且需要自己管理这些方式使用服务。示例:
//Create custom element 
this.customElement = this.renderer.createElement(customElementTag) as any; 
// Provide it all required service
this.customElement.messageService = this.messageService; 
this.customElement.configurationService = this.configurationService; 
this.customElement.logService = this.logService;

自定义元素

@input() messageService: MessageService;
@input() configurationService: ConfigurationService;
@input() logService: LogService;
  • 我想将全局应用程序的服务注入到自定义元素中构建的微型应用程序中。我真的不知道这是否可行以及如何实现...也许有可能获得这些服务并在我的应用程序中为它们提供类似的东西:
CustomElementModule.forRoot({providers:[messageService,configurationService,logService]};

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)