This is something that i have runned in a couple of times.
Say i have the following variables in my controller:
$scope.valueArr = ['Hello', 'No', 'Yes'];
$scope.myValue = 'Hello';
And i have the following ng-repeat
:
<li ng-repeat="value in valueArr" ng-class="{'active' : myValue == value}"><a>{{value}}</a> </li>
Now if i do the following:
<a ng-click="myValue = value"> </a>
Then it adds the class to the li
however it does remove the class from the previous li
But if i do the following:
<a ng-click="setMyValue(value);"> </a>
and in my controller add the function:
$scope.setMyValue = function(value){$scope.myValue = value}
Then it removes the "old" and only adds the active
class to the last pressed li
So it seems that it is not rerendering without a function in the controller. Can anyone tell me why? and when you should choose one over the other.
Note this is just one of many examples where the rerendering is not happening.