Hello, people, I'm a beginner in angular, javascript, and so on. I'm trying to display the information from a json returned by a php script, but I'm getting this error:
Duplicates in a repeater are not allowed
Angular:
angular.module("moduloJogos", []);
angular.module("moduloJogos").controller("moduloJogosCTRL", function($scope, $http) {
$http.get('jogos.php').then(function(response) {
$scope.partidas = response.data;
console.log(response.data);
});
});
HTML. Table that displays:
<tbody ng-controller="moduloJogosCTRL">
<tr ng-repeat="partida in partidas">
<td class="timeCasa">{{partida.timeCasa}}</td>
<td class="tdAposta"><input type="button" class="btn" id="{{casa + partida.idPartida + partida.cotTimeC}}" value="{{partida.cotTimeC}}"/></td>
<td class="tdAposta"><input type="button" class="btn" id="{{empate + partida.idPartida + partida.cotEmp}}" value="{{partida.cotEmp}}"/></td>
<td class="tdAposta"><input type="button" class="btn" id="{{fora + partida.idPartida + partida.cotTimeF}}" value="{{partida.cotTimeF}}"/></td>
<td>{{partida.timeFora}}</td>
</tr>
</tbody>
PHP that takes the information and mounts json:
$partidasTotais = "[";
while($jogos = $select->fetch(PDO::FETCH_ASSOC)) {
$timeCasa = $jogos['time_casa'];
$timeFora = $jogos['time_fora'];
$idMatch = $jogos['id_jogo'];
$content = $chamaURL->retornaConteudo('https://api.soccerama.pro/v1.2/odds/match/'.$idMatch.'?api_token='.$apiTOKEN);
$cotCasa = $content["data"]["0"]["types"]["data"]["0"]["odds"]["data"]["0"]["value"];
$cotEmp = $content["data"]["0"]["types"]["data"]["0"]["odds"]["data"]["2"]["value"];
$cotFora = $content["data"]["0"]["types"]["data"]["0"]["odds"]["data"]["1"]["value"];
$partidaIndividual = '{"timeCasa":'. $timeCasa.',"timeFora":'. $timeFora.',"idPartida":'. $idMatch.',"cotTimeC":'. $cotCasa.',"cotEmp":'. $cotEmp.',"cotTimeF":'. $cotFora.'},';
$partidasTotais .= $partidaIndividual;
}
$partidasTotais .= "]";
echo json_encode($partidasTotais);