I'm working on Galleries and Pictures. I'm using Flask, AngularJS, MongoDB (and mongoengine). I displayed all my object thru an API.
I got 2 kinds of objects: - Galleries objects define by id:int, title:string, owner:string, date:string, content:array[], etc... - Pictures objects define by id:int, title:string, owner:string, date:string, etc...
In the Content of Galleries which is an array, I got all the ids belonging of the gallery. [MongoDB sample][1]
When the user click on the concerned gallery, I try to list all the pictures in a HTML page template. For that I'm using a $scope variable in the controller and ng-repeat on the HTML side.
Controller:
$scope.gallery = Galleries.get({id: $routeParams.id}, function (gallery) {
for (var i = 0; i < gallery.content.length; i++){
gallery.picture = Picture.get({id: $scope.gallery.content[i].split('-')[1]});
}
});
HTML:
<tr ng-repeat="pict in gallery">
<td>{{pict.fileID}}</td>
<td>{{pict.legend}}</td>
</tr>
Unfortunately, only the last one picture in the content is displayed. The global variable in the scope isn't feeding at each content index.
How can I do to put all the picture object in an only one scope variable for using ng-repeat in the HTML view?
Thanking in advance, Have a nice day.
Galleries.get
andPicture.get
?