Behavior of assignment expression invoked by ng-click within ng-repeat

Directive ngRepeat creates a new scope for each iteration, so you need to reference your variables in parent scope.

Use $parent.selected = value, as in:

<p ng-repeat="value in values" ng-click='$parent.selected = value'>{{value}}</p>

Note: Function call propagates due to prototypal inheritance.

If you want to learn more: The Nuances of Scope Prototypal Inheritance.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)