我有以下控制器:
angular.module('samples.controllers',[])
.controller('MainCtrl', ['$scope', 'Samples', function($scope, Samples){
//Controller code
}
这取决于以下服务:
angular.module('samples.services', []).
factory('Samples', function($http){
// Service code
}
尝试使用以下代码测试控制器:
describe('Main Controller', function() {
var service, controller, $httpBackend;
beforeEach(module('samples.controllers'));
beforeEach(module('samples.services'));
beforeEach(inject(function(MainCtrl, Samples, _$httpBackend_) {
}));
it('Should fight evil', function() {
});
});
但出现以下错误:
Error: Unknown provider: MainCtrlProvider <- MainCtrl.
Ps 试过下面的帖子,似乎没有帮助