我在我的角应用中使用ng-strict-di
模式。它会抛出错误
throbberController is not using explicit annotation and cannot be invoked in strict mode
我的代码是:
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'];
}
]);
如何明确注射?我做错了吗?帮我解决这个问题。
答案 0 :(得分:2)
app.directive('throbberDirective',
[
function(){
return {
restrict: "EA",
templateUrl: "common/utils/throbbers/throbber.html",
controller: throbberController
}
}
]);
app.controller('throbberController', throbberController);
throbberController.$inject = ['$scope', '_$ajax'];
function throbberController($scope){
$scope.throbber = _$ajax.getThrobberConfigs();
$scope.throbber.templateName = $scope.throbber.templateName;
}