각도 응용 프로그램에서 ng-strict-di
모드를 사용하고 있습니다.다음과 같은 방법으로 지시문 컨트롤러에 종속성을 주입하는 방법은 무엇입니까?
app.directive('throbberDirective',
[
'_$ajax',
function(_$ajax){
return {
restrict: "EA",
templateUrl: "common/utils/throbbers/throbber.html",
controller: throbberController
}
function throbberController($scope){
$scope.throbber = _$ajax.getThrobberConfigs();
$scope.throbber.templateName = $scope.throbber.templateName;
}
throbberController.$inject = ['$scope'];
}
]);
방법은 명시 적으로 주입 : 그것은
throbberController is not using explicit annotation and cannot be invoked in strict mode
내 코드는 오류가 발생합니다? 내가 뭐 잘못하고 있니? 이 문제를 해결하도록 도와주세요.
지시어와 컨트롤러를 분리 된 두 개의 파일로 분리 해보십시오. 그런 다음 평소처럼 컨트롤러에서 주입을 할 수 있습니다. – rrd
왜 여기서 일어나지 않습니까? – SaiUnique