我在我的角度应用程序中使用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'];
}
]);
如何明确地注入?我做错了什么?帮我解决这个问题。
尝试将指令和它的控制器分隔成两个单独的文件。然后你可以在控制器中像通常那样进行注射。 – rrd
为什么它不在这里发生? – SaiUnique