0
이 문제는 나를 미치게합니다.각도 조절기 대 폐쇄 형
시험 번호 :
i 컨트롤러 기능은 예를 들어 전역에 정의되어 있다면 작동describe('controller', function(){
module('controllers');
var createCtrl;
beforeEach(inject(function($injector){
$rootScope = $injector.get('$rootScope');
var $controller = $injector.get('$controller');
createCtrl = function(){
return $controller('controller', {
$scope: $rootScope
});
}));
it('should create a controller', function(){
var ctrl = createCtrl();
});
});
난 (이들의 조합)를 폐쇄로 배열하는 기능 자체를 이동하거나 모듈 코드를 감싸는 경우
angular.module('controllers', [])
.controller('controller', ['$scope', controller]);
function controller($scope){}
하지만 :
(function(angular){
angular.module('controllers', [])
.controller('controller', ['$scope', function($scope){}]);
})(angular);
시험이 오류 Error: [ng:areq] Argument 'controller' is not a function, got undefined
아이디어가 있으십니까? 전이 컨트롤러가 글로벌 범위를 오염시키지 않도록 정말로 필요합니다.
굉장합니다, 감사합니다! 난 아직도 뭔가 모의하지 않는 모듈()와 mock.module() 사이의 차이점을 이해할 수 없다. 그러나 이것은 어떤 이유로 도움이된다. 감사. –