【问题标题】:Failed to instantiate module formlyBootstrap无法实例化模块 formlyBootstrap
【发布时间】:2015-07-14 12:18:13
【问题描述】:

我已经通过 bower 在我一直从事的项目中安装了 angular-formly-templates-bootstrap。但是当我尝试以角度注入它时,我收到以下错误:

Uncaught Error: [$injector:modulerr] Failed to instantiate module bandar due to:
Error: [$injector:modulerr] Failed to instantiate module formlyBootstrap due to:
Error: [$injector:nomod] Module 'formlyBootstrap' 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.
http://errors.angularjs.org/1.4.1/$injector/nomod?p0=formlyBootstrap
    at http://localhost:3000/bower_components/angular/angular.js:68:12
    at http://localhost:3000/bower_components/angular/angular.js:1949:17
    at ensure (http://localhost:3000/bower_components/angular/angular.js:1873:38)
    at module (http://localhost:3000/bower_components/angular/angular.js:1947:14)
    at http://localhost:3000/bower_components/angular/angular.js:4355:22
    at forEach (http://localhost:3000/bower_components/angular/angular.js:336:20)
    at loadModules (http://localhost:3000/bower_components/angular/angular.js:4339:5)
    at http://localhost:3000/bower_components/angular/angular.js:4356:40
    at forEach (http://localhost:3000/bower_components/angular/angular.js:336:20)
    at loadModules (http://localhost:3000/bower_components/angular/angular.js:4339:5)

问题是,bower 没有在浏览器中加载 angular-formly-templates-bootstrap。还有一些其他的包正在使用 bower 加载到浏览器中。但是我不知道formlyBootstrap有什么问题。

【问题讨论】:

  • Angular 找不到该模块,所以看起来你要么没有定义它,要么没有正确定义它,要么你没有在 HTML 页面中加载它。
  • 我添加了一些额外的解释。我希望它有所帮助......@MattHerbstritt
  • 如果不自己重新配置,这些模板无法与 bower 一起正常工作
  • @charlietfl 我在其文档中找不到有关重新配置它的信息。有没有说明正确方法的文件?!
  • 您确定已在页面中包含angular-formly-templates-bootstrap 脚本吗?这就是所有the examples 正在做的事情。另外,请确保将其包含在自定义脚本之前。

标签: javascript angularjs twitter-bootstrap angular-formly


【解决方案1】:

您是否使用 gulp 来注入 bower 依赖项?如果是这样,在 gulp config 中找到类似的东西

exports.wiredep = {
  exclude: [/bootstrap.js$/, /bootstrap-sass-official\/.*\.js/, /bootstrap\.css/],
  directory: 'bower_components'
};

所以所有文件都以未注入的“bootstrap.js”结尾。你可以用类似的东西来改变它

exports.wiredep = {
  exclude: [/[^-]bootstrap.js$/, /bootstrap-sass-official\/.*\.js/, /bootstrap\.css/],
  directory: 'bower_components'
};

【讨论】:

  • 希望我能给你更多我的观点。这个解决方案为我节省了很多时间。
【解决方案2】:

遇到同样的错误。我正在使用 gulp 角度生成器,它似乎忽略了正式的引导程序。我将 bower_components 中用于 angular-formly-bootstrap-template 的主文件更改为 dist/...bootstrap.min.js。之后开始工作。似乎生成器忽略了最后带有 bootstrap.js 的文件

【讨论】:

    猜你喜欢
    • 2014-05-30
    • 2014-06-04
    • 2016-05-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多