Increment Inside Angular Expression
I am trying to show some divs (which are under 3+ ng-repeats) conditionally and then increment a counter variable which. The counter contributes in the conditions which decide the
Solution 1:
Why just do not use method like:
<button ng-show='increaseFoo() < SOME_LIMIT'>press me</button>
controller
$scope.SOME_LIMIT = 10;
$scope.foo = 8;
$scope.increaseFoo = function(){
return $scope.foo++;
};
if $scope.foo = 8;
, ng-show
returns true
if $scope.foo = 9;
, ng-show
returns false
Solution 2:
The question is a bit ignorant to the fact that such an effort triggers cyclic $digest
calls which breaks. (Just for the sake of making some sense out of this question I'm giving my solution. Hope it will help someone trying this stuff) The solution I finalized involved flattening all the lists to a single list and switch
ing to show the icon for a particular value of $index
.
Post a Comment for "Increment Inside Angular Expression"