Counter not working… Help


#1

In main controllers I have

$scope.decrease = function(index) {
$scope.exercises[$index].decrease -= 1;
},
$scope.increase = function(index) {
$scope.exercises[$index].increase += 1;
}

And in view I have

$scope.decrease = function(index) {
$scope.exercises[$index].decrease -= 1;
},
$scope.increase = function(index) {
$scope.exercises[$index].increase += 1;
}

Where am I going wrong?


#2

Finally got it working...

MAIN CONTROLLER

  $scope.decrease = function(index) {
    $scope.exercises[index].count -= 1;
  },
  $scope.increase= function(index) {
    $scope.exercises[index].count += 1;
  }

VIEW

<div class="col-xs-4 counters">
        <span class="decrease" ng-click="decrease($index)"> - </span>
        <span class="count"> {{exercise.count}} </span>
        <span class="increase" ng-click="increase($index)"> + </span>
</div>

#3

Thanks for this,
I was missing the $ in

ng-click="increase($index)"

#4

Thanks, man. Had some confusion. Reviewed this and worked it out.


#5

Thanks for the contribution it really helped me understand where I was going wrong.


#6

Why do we need the $? Did I miss something in one of the lessons?


#7

Does anyone know how to make the decrease not less than 0 to fit the this case...
and how we able to do that?


#9