我想在“link”属性中访问“num”。但我不能只做value={{num}}
。这样做的正确方法是什么?
<div class="customDirective" ng-repeat="num in [1,2,3]"></div>
function customDirective(loggedUserService) {
return{
restrict: "C",
link: function (scope, element, attrs) {
//I would like to access num
},
template: "<div>some stuff</div>"
};
}
app = angular
.module('myApp', [])
.directive('customDirective', customDirective)
答案 0 :(得分:2)
link: function (scope, element, attrs) {
alert(scope.num);