I have JSON object from server and requirement is to always display last item from the array items
. how can i achieve that task using AngularJs or native JavaScript ?
Below case i have to display text Chief Administrative Officer
.
main.js
angular.forEach($scope.rcsaErhTreeData, function(val) {
angular.forEach(val, function(val) {
console.log('this is the array value', val[0].text);
});
});
json.js
[{
"uid": null,
"index": 0,
"selected": null,
"expanded": null,
"id": 2701,
"text": "BAC Enterprise Wide",
"parentId": 0,
"items": [{
"uid": null,
"index": 0,
"selected": null,
"expanded": null,
"id": 4114,
"text": "Chief Administrative Officer",
"parentId": 2701,
"items": []
}]
}]