Issue with Console: SyntaxError: Unexpected token { in JSON at position 119
Xcode controller:
str="http://www.website.com/user-orders.php?e="+$scope.useremail;
$http.get(str)
.success(function (response){
$scope.user_orders = response;
sessionStorage.setItem('userorders_id', $scope.user_orders.id);
$scope.orders = [
{ id: $scope.user_orders.id,
uniqueid: $scope.user_orders.uniqueid,
platenumber: $scope.user_orders.platenumber,
paymentstatus: $scope.user_orders.paymentstatus,
orderstatus: $scope.user_orders.orderstatus
}
];
}).error(function() {
var alertPopup = $ionicPopup.alert({
title: 'Failed to get orders!',
template: 'Please check your credential'
});
});
JSON data:
{"records":{"id":"21","uniqueid":"42803122423","platenumber":"00000","paymentstatus":"Success","orderstatus":"Queued"},{"id":"22","uniqueid":"428032438","platenumber":"00000","paymentstatus":"Success","orderstatus":"Queued"},}
Template layout:
<ion-content ng-controller="orderslistCtrl">
<ion-list>
<ion-item ng-repeat="order in orders" href="#/app/orderslist/{{order.id}}">
{{order.id}}
{{order.uniqueid}}
</ion-item>
</ion-list>
</ion-content>
When only 1 item is present in "records":
{"records":{"id":"21","uniqueid":"42803122423","platenumber":"00000","paymentstatus":"Success","orderstatus":"Queued"}}
Result will display only 1 item. If multiple records are loaded, it leads to an error.