In my html I show dynamically information brought from a web services and I show them with ng-repeat
as follows:
to this I want to add this numerical check to add and subtract amount
but I can not find the way to associate the check to each object in the array, that is to say that it shows me the price to each one that corresponds, until now it takes the price of the first value and adding all together, the same when subtracting
This is my code:
<ion-list class="text-left" style="padding-left:1px;">
<ion-item class="item-remove-animate item-avatar item-icon-right" ng-repeat="co in coffe" type="item-text-wrap" href="">
<div class="row">
<div class="col-sm-8">
<h2 style="color:#878787;"><b>{{co.producto}}</b></h2>
<div style="width:250px;">
<h5 style="color:#878787;">{{co.descripcion}}</h5>
</div>
<h4 style="color:#878787;">{{co.calorias}}</h4>
</div>
<div class="col-sm-4 text-right" style="width:90px">
<h-number value="test.count" min="1" max="5" step="1" change="onNumberChanged(co.precio)"></h-number>
<div class="precio">
${{total}}
</div>
</div>
</div>
</ion-item>
</ion-list>
Try putting id
and for
but it did not work! : c
in controller the thing is this way not to confuse:
$scope.test = {};
$scope.test.count = 1;
$scope.onNumberChanged = function(valor){
var numero = parseInt(valor);
$scope.total = numero * $scope.test.count
}
HernannMovil.Getcafe({
id_servicio: id
},function(response){
console.log(response);
$scope.coffe = response;
});
First I define the variables, then I create the function onNumberChanged
and finally consume the data with getCofe
that brings what is in the array of the image ...