I need to create an array based in the following features:
Every time the ng-repeat directive list an object the init() function automatically sends these parameter to the controller in order to get an object.
<div data-ng-repeat="user in users" data-ng-init="init(user.id)">
In the other side, the init() function receive these parameter and then returns an object.
// Suppose I have 5 parameters in order to get 5 publications
$scope.init = function(id){
$http.get("getPublicationByID/"+id)
.success(function(data, status, headers, config){
// Here is the object that I need to create an array
$scope.publication = data; })
.error(function(data, status, headers, config){
$log.error("Error!")})
}
My question is, how can I create an array based on all these objects?