I am encountering an issue while trying to display values from a JSON array on my Angular JS table. The web service is called and the JSON array is retrieved successfully when the page loads. However, I am facing difficulties in displaying these values on the view. Despite following the same procedure as before, the data does not appear as expected.
Below is the controller code:
assets.controller('DetallTipusCtrl', function ($scope, $http, $routeParams){
$http.get('http://10.0.203.73/WS/ws.php/tipusactius/getDetails/'+$routeParams.param).success(function(data) {
$scope.atrb = data;
});
$scope.param = $routeParams.param;
});
And here is the corresponding view:
<table class="table" ng-controller="DetallTipusCtrl">
<tr>
<th>#</th>
<th><a href="">Atribut</a></th>
<th><a href="">Mida</a></th>
<th><a href="">Tipus</a></th>
</tr>
<tr ng-repeat="atribut in atrb | orderBy:sortField:reverse">
<td></td>
<td>{{atribut.nomAtribut}}</td>
<td>{{atribut.midaAtribut}}</td>
<td>{{atribut.valor}}</td>
</tr>
</table>
Although the JSON array is correctly structured, I am unable to see any output on the view. If anyone has advice or solutions, your help would be greatly appreciated. Thank you!
Edit: The JSON object:
{"nomAtribut":"fgdsgsfd","midaAtribut":"16","valor":"String","tipus_actius_idtipus_actius":"26","nom":"yiuhdfiau837629875wf"}
Solution:
The issue was due to the JSON array being presented as a single JSON object. To iterate over and display its properties, I used the following approach:
<tr ng-repeat="(key, value) in atrb">
<td>{{value.propertie}}</td>
</tr>