角度アプリで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
私のコードは、エラーがスローされますか?私は間違って何かしていますか?私はこれを解決するのに役立ちます。
ディレクティブとそのコントローラーを2つの別々のファイルに分けてください。それからあなたはコントローラの中で通常どおりに注射をすることができます。 – rrd
なぜここでは起こっていないのですか? – SaiUnique