I got data form API, That data has a sting in they key.
And I much to use data in a key.
angular.forEach(response['data'], function(val, key) {
// Do something.
});
And I don’t know how to use angular.forEach
.
What should i do??
I got data form API, That data has a sting in they key.
And I much to use data in a key.
angular.forEach(response['data'], function(val, key) {
// Do something.
});
And I don’t know how to use angular.forEach
.
What should i do??
That’s Angular 1 syntax, and you’ve tagged your thread with the “Ionic 2” category. Are you using v1 or v2 and what are you actually trying to achieve?
I use V2. It can use.
for(let data of response['data']) {
// Do something.
}
But, It not what I want. Because I want to get a key.
From Stackoverflow
Object.keys(obj).forEach(function(key,index) {
// key: the name of the object key
// index: the ordinal position of the key within the object
});
Wow. Thank you very much.