Passing variable to Angular Directive

前端 未结 1 571
鱼传尺愫
鱼传尺愫 2020-12-13 18:21

If I have a directive myDir and I call it within ng-repeat like so


1条回答
  •  忘掉有多难
    2020-12-13 19:01

    Try

    
    

    Then

    app.directive('myDir', function () {
      return {
        restrict: 'E',
        scope: {
          myindex: '='
        },
        template:'
    {{myindex}}
    ', link: function(scope, element, attrs){ scope.myindex = attrs.myindex; console.log('test', scope.myindex) } }; })

    Demo: Plunker

    0 讨论(0)
提交回复
热议问题