【问题标题】:Adding modules in angular-meteor在 angular-metor 中添加模块
【发布时间】:2019-07-14 19:32:24
【问题描述】:

我正在使用 angular-meteor (Angular1) 开发一个网络应用程序。这使用 webpack 作为模块捆绑器。自从我开始我就发现不可能将 npm/bower 模块注入我的应用程序模块。

我经常遇到以下错误:

Error: [$injector:nomod] Module xxx is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

我通常遵循官方文档,其中包括:

  • 下载 npm 模块
  • 在我的 index.html 中包含脚本
  • 将模块添加到我的应用模块中

但这总是会出现上述错误。

然后我尝试不同的技术,例如使用以下方法在页面顶部导入模块:

import exampleModule from 'angular-example-module';

并将 exampleModule 添加到我的模块列表中,但似乎没有任何效果。

我以前使用没有 webpack 的 angular,从来没有遇到过这个问题。我错过了什么吗?有什么我不知道的特定程序吗?

【问题讨论】:

    标签: angularjs webpack module angular-meteor


    【解决方案1】:

    找到答案,以防其他人有同样的问题。

    您必须像这样在主 javascript 文件中导入模块:

    import moduleVariable from '<path-to-module>';
    

    然后将 moduleVariable 包含在应用程序模块的依赖项中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-03-01
      • 2017-05-16
      • 2017-06-26
      • 1970-01-01
      • 1970-01-01
      • 2017-04-10
      • 2016-07-14
      • 1970-01-01
      相关资源
      最近更新 更多