我在使用AngularJS 1.5版本的应用程序中引入了ngMaterial。一切看起来不错,但因果测试案例失败,并显示消息
“错误:[$ injector:nomod]模块'ngMaterial'不可用!您拼错了模块名称或忘记了加载它。”
下面是我的代码。有人可以帮助解决此错误。
(function (angular) {
'use strict';
var myComponentComponent = {
templateUrl: 'app/myComp/myComp.html',
controller: myComponentController,
controllerAs: 'vm'
};
/* @ngInject */
function myComponentController($sce, $templateCache, viewport) {
var vm = this;
}
angular.module('core', ['ngMaterial', 'ngMessages'])
.component('myComponent', myComponentComponent);
})(angular);
describe('testCore', function () {
beforeEach(module('core'));
beforeEach(module('ngMaterial'));
beforeEach(module('ngMessages'));
var $window;
var $componentController;
var scope;
var $rootScope;
var controller;
beforeEach(inject(function (_$window_, _$componentController_, _$rootScope_) {
$window = _$window_;
$componentController = _$componentController_;
$rootScope = _$rootScope_;
scope = $rootScope.$new();
controller = $componentController('myComponent', null, scope.mockData);
scope.$apply();
}));
it('should initialize component', function () {
});
});