0

我想在“link”属性中访问“num”。但我不能只是这样做value={{num}}。这样做的正确方法是什么?

HTML

<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)
4

1 回答 1

2
link: function (scope, element, attrs) {
    alert(scope.num);
于 2013-09-27T10:09:07.257 回答