【问题标题】:Is it a good practice to bind factory with ng module?将工厂与 ng 模块绑定是一种好习惯吗?
【发布时间】:2019-05-10 03:10:42
【问题描述】:

下面我正在尝试将工厂与ng 模块绑定,这有助于我直接注入。

var module = angular.module("ng");

module.factory("commonService", ["$http"]);

提前致谢。

【问题讨论】:

  • 我不推荐monkey patching核心ng模块。不小心编写或记录不善的猴子补丁可能会导致问题。见Pitfalls of Monkey Patching
  • 感谢@georgeawg,但在我的情况下,我暂时不会更新库。

标签: javascript html angularjs frontend


【解决方案1】:

我在这里得到了答案,没有模块就无法创建工厂。我们可以将工厂与ng 模块绑定,但这不是一种好的做法。

找到答案here

【讨论】:

    猜你喜欢
    • 2017-12-09
    • 1970-01-01
    • 2019-08-14
    • 1970-01-01
    • 1970-01-01
    • 2013-03-28
    • 2019-09-26
    • 2012-08-22
    • 1970-01-01
    相关资源
    最近更新 更多