【发布时间】:2015-07-24 16:00:33
【问题描述】:
我在我的应用程序中使用“ng-strict-di”指令来防止缩小失败。但现在我的指令出错了。
错误:[$injector:strictdi] function($scope, element, attrs) 没有使用显式注解,无法在严格模式下调用
如何将 $scope 显式添加为匿名控制器函数的依赖项?这是我的指令。
var myApp = angular.module("myApp",[]);
myApp.directive('myDirective', function(){
return{
restrict: 'A',
template: '<h4> {{myController.msg}} </h4>',
controller: function($scope, element, attrs){
$scope.myController = this;
this.msg = "Hello world";
};
});
我试过了:
var myApp = angular.module('myApp ', ['$scope'])
但我收到此错误: 错误:[$injector:modulerr] 无法实例化模块
【问题讨论】:
标签: angularjs angularjs-directive