Ng-mouseenter not working inside ng-repeat

ng-mouseenter doesn't work inside my ng-repeat, it only works outside of it. Could you explain what is happening here? http://plnkr.co/edit/BklqI09raI18RAaqmca2?p=preview

<p ng-repeat="i in [1,2]" ng-init="n=0">
<span ng-mouseenter="n = n + 1">ng-repeat {{i}}</span>
</p>
<p><span ng-mouseenter="n = n + 1">Outside the repeat</span></p>
<pre>n : {{n}}</pre>

      

+3


source to share


1 answer


When you use ng-repeat, an area is created inside it. If you want to print n in the parent area, change the parent with $ parent in ng-repeat: ng-mouseenter="$parent.n = $parent.n + 1"



+3


source







All Articles