Array of json values: how to get elements using Angular js?

A call on api returns this json:

[ { "RESULT": { "TYPES": [ "bigint", "varchar", "varchar", "varchar", "varchar", "varchar", "date", "varchar", "int", "int", "varchar" ], "HEADER": [ "kvk", "bedrijfsnaam", "adres", "postcode", "plaats", "type", "anbi", "status", "kvks", "sub", "website" ], "ROWS": [ [ "273121520000", "Kinkrsoftware", <-- this is the value i want "Oude Trambaan 7", "2265CA", "Leidschendam", "Hoofdvestiging", null, null, "27312152", "0", null ] ] } } ] 

I can not change the api code.

I am using Angular and I do not see to access the values.

This is my controller:

  .controller('MainCtrl', function($scope, $http, $log, kvkInfo) { kvkInfo.success(function(status, data) { $scope.name = status; $scope.bedrijf = data; $scope.status = status; }); }); 

I tried

data.RESULT.ROW, data.RESULT.ROW [1], data.RESULT [0] .ROW, data.RESULT [0] .ROW [1], data.ROW [1]

How can I get this item?

+7
json angularjs
source share
2 answers

What you get begins with [ , so this is an array. Therefore you need data[0] .

The first element of this array ( data[0] ) is the object (it starts with { ), which has the RESULT attribute. That way you can use data[0].RESULT .

The value of the RESULT attribute is another object with the ROWS attribute (note the final S ). That way you can use data[0].RESULT.ROWS .

The ROWS value is an array containing another array, so you need data[0].RESULT.ROWS[0][1] .

+25
source share

The api result is wrapped in an array, so you need to keep its first element in scope instead of the entire array.

+2
source share

All Articles