Reputation: 337
I am new to Javascript / Ionic so I try to wrap my head around different concepts.
I have a function that retrieve the users like this :
$timeout(function(){
$scope.users = snapshot1.val();
console.log($scope.users);
})
Which gives me the information in the console.
Now, I would like to isolate the field "name" but when I do :
snapshot1.val().name;
It does not work. Is there a way to grab only a specific field ?
Upvotes: 0
Views: 30
Reputation: 138557
console.log(snapshot1.val().map(el=>el.name));
If its really an Array, you can generate a new Array containing just the name property using Array.prototype.map...
Upvotes: 2