无法实例化formlyBootstrap模块

时间:2015-07-14 12:18:13

标签: javascript angularjs twitter-bootstrap angular-formly

我已经通过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的问题是什么。

2 个答案:

答案 0 :(得分:11)

您是否正在使用gulp注入bower依赖项?如果是这样,请在gulp配置中找到类似的内容

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'
};

答案 1 :(得分:0)

得到了同样的错误。我正在使用gulp角度发生器,它似乎忽略了形式的自举。我将bower_components中的主文件更改为angular-formly-bootstrap-template到dist / ... bootstrap.min.js。之后开始工作。好像生成器忽略了最后有bootstrap.js的文件