I have a ng-click
function:
ng-click = "adicionar(0);"
This function ng-click
is inside the ng-repeat = "mercadoria in listademercadoria"
loop.
Is there a way to pass information according to repeat where it is contained?
How I'm trying, unsuccessful:
ng-click = "adicionar({{mercadoria.mercadoria}});"
Follow AngularJS code:
angular.module('meumodulo', [])
.controller('mercadoriaCarrinho', function($rootScope, $http) {
var ctrl = this;
$rootScope.listademercadoria = [];
$rootScope.mercadoria0 = {
id: 'id1',
setor: 'setor1',
foto: 'foto1',
descr: 'descr1',
de: de1,
por:por1,
mercadoria: '0',
quantidade: 1
}
$rootScope.listademercadoria.push($rootScope.mercadoria1);
$rootScope.mercadoria1 = {
id: 'id2',
setor: 'setor2',
foto: 'foto2',
descr: 'descricao2',
de: de2,
por: por2,
mercadoria: '1',
quantidade: 1
}
$rootScope.adicionar = function (a){
{
$rootScope.listademercadoria[a].quantidade=$rootScope.listademercadoria[a].quantidade + 1;
}
}
});
HTML button that would perform the action of adding one to the quantity in the merchandise with index where it is contained:
<button ng-click = "adicionar({{mercadoria.mercadoria}});"> + </button>
I emphasize that functions of another type, other buttons parallel to it, are working correctly, but only in this function I can not make it work correctly.