I'm using Angular JS to show a list of items from a JSON get request.
I'm able to retreive the items, but i'm not able to show them in the right order without repeating.
My JSON file looks like :
[
{
"id":"32",
"competiton":"série1",
"game":"A- B"
},
{
"id":"33",
"competiton":"série1",
"game":"C - D"
}
]
here is my code to retrieve the items :
app.controller('customersCtrl', function($scope, $http) {
$http.get("http://myserver.com/matches?date=2015-05-18")
.success(function (response) {
$scope.matches = response;
for (var i = 0; i < response.length; i++) {
setName($scope.matches, i);
}
});
var setName = function (matches, index) {
$http.get("http://myserver.com/ofc/competitions/" + matches[index].idCompetition)
.success(function (response) {
matches[index].competition = response.name;
$scope.competitions[index] = response.name;
});
}
});
and here is how i'm showing them :
<div ng-controller="customersCtrl">
<div class="list">
<div class="item item-divider" ng-repeat="m in matches">
{{ m.competition}}
</div>
<a class="item" href="#" ng-repeat="m in matches">
{{ m.game }}
</a>
</div>
</div>
Items are showig like :
Série A
Série A
A - B
C - D
I want to show them like :
Série A
A - B
C - D .... etc