All:
我是棱角的新手,现在,我尝试声明一个指令:
var app = angular.module("vp", []);
app.directive("outter", ["$compile", "$scope", function($compile, $scope){
return {
restrict: "AE",
compile: function(tEL, attrs){
return {
post: function(scope, EL, attrs){
}
}
}
};
}]);
在我的 HTML 中:
<body ng-app="vp">
<outter></outter>
</body>
但是我不断收到这样的错误:http://errors.angularjs.org/1.2.26/$injector/unpr?p0=%24scopeProvider%20%3C-%20%24scope%20%3C-%20outterDirective
谁能给我一些线索?
谢谢
$scope不是
服务,因此不是可以注入的东西。您可以访问链接函数中的范围。
您应该将指令定义更改为:
app.directive("outter", ["$compile" function($compile){