I have this code in controller:
$scope.$on("enterprise_ids.loaded", function(event){
$scope.enterprise_ids = Enterprise.enterprise_ids;
angular.forEach($scope.enterprise_ids, function(value, key) {
console.log("id =>", value);
VoteServices.checkVoted(value).then(function (response){
console.log("res", response);
if(response.data == null){
console.log("inside true");
$scope.votes_map = new function () {
this[value] = {
isVoted: true
};
};
}
else{
$scope.votes_map = new function () {
this[value] = {
isVoted: false
};
};
}
});
VoteServices.loadVoteById(value).then(function (response) {
$scope.votes_map = new function () {
this[value] = {
up: response.data.up,
down: response.data.down
};
};
});
});
console.log("votes map boolean ",$scope.votes_map);
});
$scope.enterprise_ids is an array(4)
Here is a service that i call in foreach
service.prototype.checkVoted = function(enterprise_id){
var url =
jsRoutes.controllers.VotesController.checkVoted(enterprise_id).url;
return $http({
method: 'GET',
url: url,
isArray: true
}).success(function (data) {
return data;
}).error(function error(error) {
console.log(error.data);
});
};
console.log("id =>", value); it show all value of the array
but it didn't run VoteServices.checkVoted.
Can someone explain for me pls?
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.