Quantcast
Channel: How do I parse json array object with Angular.js? - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by iulia for How do I parse json array object with Angular.js?

$
0
0

Edit, here is the AngularJS solution.

$http.get("your_data").success(function (data) 
{ 
   $scope.users = data.messages; 
   console.log("users" , $scope.users); 
}); 

and in HTML

<div ng-repeat="user in users" > 
   <div>Rich: {{user.body.rich}}</div> 
    <div>URL: {{user.url}}</div> 
</div>

To directly access the rich property, you can use this code: user.messages[0].body["rich"]. Similar goes for url Explanation: messages has an array with one element, and the object body which has the property rich. See below my results after debugging in the console. Console view of the JSON


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>