How to reach variable outside the ng-repeat scope

前端 未结 2 1599
慢半拍i
慢半拍i 2021-01-26 12:18

Is possible to reach variable outside the ng-repeat scope?

jsfiddle: http://jsfiddle.net/zcbhubrw/

Here is the code:

HTML



        
2条回答
  •  北荒
    北荒 (楼主)
    2021-01-26 12:49

    You can create function in the controller to set the count or refer the parent scope from inside the ng-repeat

    ng-click="$parent.count = $index"
    

    using parent scope

    using function

提交回复
热议问题