【问题标题】:Using provider to create another provider使用提供者创建另一个提供者
【发布时间】:2021-07-30 23:27:16
【问题描述】:

我正在尝试使用相同的提供程序,并在引导期间将其注入另一个提供程序。

  { provide: '$http', useFactory: (config: any) => httpFunc(config), deps: [configService] },

  { provide: '$pab', useFactory: (config,  http) => new pabLite(config, http), deps: [configService, Inject('$http') http] }

剂量似乎有效。创建 $pab 提供程序时,如何注入 $http 提供程序 我也尝试将 Inject('http') 私有 http 移动到 pablite 中,但它似乎在初始化时变得未定义

【问题讨论】:

  • 你试过deps: [configService, http$]吗?

标签: angular provider


【解决方案1】:

您应该将其提供为:

deps: [configService, http$]

【讨论】:

    猜你喜欢
    • 2020-03-22
    • 2020-01-06
    • 2017-01-08
    • 1970-01-01
    • 1970-01-01
    • 2021-07-17
    • 2022-06-24
    • 2019-04-04
    • 1970-01-01
    相关资源
    最近更新 更多