Hello, guys, I'm a beginner in angular, and I'd like to know what I'm doing wrong here. Look at this: Every time I click a button I want it to add some "modified" information from an object called a match to the betting object. The problem is that in fact, instead of adding it it overrides.
This is the function:
$scope.fazAposta = function(partida, tipo) {
var time;
var partidaA = partida.timeCasa + " x " + partida.timeFora;
var cotacaoA;
var idpart = partida.idPartida;
switch (tipo) {
case 1:
cotacaoA = partida.cotTimeC;
time = partida.timeCasa;
break;
case 2:
cotacaoA = partida.cotTimeF;
time = partida.timeFora;
break;
case 0:
cotacaoA = partida.cotEmp;
time = "Empate";
break;
}
$scope.apostas = [
{timeApostado: time, partidaApostada: partidaA, cotacaoApostada: cotacaoA, idDaPartida: idpart}
];
$scope.apostas.push(angular.copy(apostas));
}
Oh, if it is necessary in any way, the starting object is coming from ajax made by one of a php script.
Here's where I'm displaying some betting information:
<h3 id="apH3">Apostas Simples</h3>
<div class='apostado' ng-repeat="aposta in apostas track by $index">
<h1 name='time'>{{aposta.timeApostado}}</h1>
<h2 name='partida'>{{aposta.partidaApostada}}</h2>
<h2 name='cotacaoApostada'>{{aposta.cotacaoApostada}}</h2>
</div>
</div>