I'm wanting to iterate through multiple JSON objects i've pulled from my database to display the containing data. I'm having trouble getting comments, comments contains an array of strings, however, when i'm passing the objects out they're reamining objects.
Here are my JSON objects:
{
eventShow :
[
{
"_id" : ObjectId("5898dabd721461267c6b0ca6"),
"username" : "larry",
"type" : "Crosscountry",
"name" : "Muddy run",
"rating" : 8,
"description" : "Had a brilliant time, got a bit dirty but would definitely recommend!",
"distance" : "6",
"comments" : [
"Looks like you had fun, would love to join you next time!",
"This definitley isn't my kind of thing..."
],
"__v" : 0
},
{
"_id" : ObjectId("5898e575721461267c6b0ca7"),
"username" : "larry",
"type" : "Short distance bike ride",
"name" : "Bike sprint!",
"rating" : 10,
"description" : "Gotta go fast!",
"distance" : "1",
"comments" : [ ],
"__v" : 0
}
]
}
My HTML:
<ul ng-show="hasEvent" ng-repeat="x in eventShow">
<li>
{{'Event Name: ' + x.name}}
</li>
<li>
{{'Type: ' + x.type}}
</li>
<li>
{{'Distance: ' + x.distance + ' miles'}}
</li>
<li>
{{'Rating: ' + x.rating}}
</li>
<li>
{{'Description: ' + x.description}}
</li>
</ul>
<hr>
<div class="actionBox">
<ul class="commentList" ng-repeat="y in x.comments">
<li>
<div class="commentText">
<p class="">{{y}}</p>
</div>
</li>
</ul>
</div>
How would I go about displaying all comments in a readable fashion, would JSON.stringify() be the right way to go?
A $http.get() which retrieves the JSON object from my mongoDB database is being called from my backend and passing a JSON object back to my services, which is being called from my controller, then... A JSON object is being passed into $scope.eventShow.
I've managed to display all comments with a nested ng-repeat however still need to get them as strings. As shown here