【问题标题】:Error: [$injector:nomod] Module 'ui.bootstrap' is not available! while Karma run in webstorm错误:[$injector:nomod] 模块 'ui.bootstrap' 不可用!而 Karma 在 webstorm 中运行
【发布时间】:2014-03-27 18:49:40
【问题描述】:

您好,我在运行 karma 测试运行时在 webstorm 中收到以下错误

Error: [$injector:nomod] Module 'ui.bootstrap', 'ui.unique' 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.

我在互联网上查看,他们说检查依赖文件 ui.bootstrap 可能会这样丢失。

但应用程序运行良好

只在测试时显示此错误

在我的 karma.conf.js 中

files: [
            //angular files

            'app/js/vendor/angular/ui.bootstrap.js',
            'app/js/vendor/angular/ui.bootstrap-0.10.0.js',

            'app/js/vendor/angular/angular.js',
            'app/js/vendor/angular/angular-mocks-0.10.6.js',

            'app/js/app.js',
            'test/**/*Spec.js'
        ], 

在我的模块声明中

var myApp = angular.module('myApp', ['ui.bootstrap']);

你能帮忙吗??

【问题讨论】:

    标签: angularjs angular-ui-bootstrap karma-runner karma-jasmine


    【解决方案1】:

    ui.unique 是来自angular-ui-utils 的模块。如果使用的话,它必须包含在 karma conf 中并注入到应用程序中。

    var myApp = angular.module('myApp', ['ui.bootstrap', 'ui.utils']);
    

    或者你可以专门注入ui.unique而不是注入ui.utils,如果只使用唯一的模块。

    【讨论】:

    • 终于修复了!谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-23
    • 1970-01-01
    • 2023-04-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多