Reputation: 135
ng-mouseenter doesn't work inside my ng-repeat, it works only outside it. Can you please explain what's 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>
Upvotes: 3
Views: 2643
Reputation: 29
When you use ng-repeat, a scope inside it is created. If you want to print n in the parent scope, modify the parent by using $parent in the ng-repeat:
ng-mouseenter="$parent.n = $parent.n + 1"
Upvotes: 3