How do i get deferre.resolve from a function?
my Controller calls this:
service.getData().then(function(response){ //myFunc deferred response});
in Service:
var _getData = function (){
$http.get(url).success(function(response){
deferred.resolve(_myFunc(response.Message)); // or just myFunc doesnt matter
});
return deferred.promise; //it returns in the end of the function
}
and myFunc has also:
$http.get(url).success(function(response){
deferred.resolve(response);
});
return deferred.promise; // also my Func is returning
so i need the deferred resolve of myFunc, which is called in another func which is called in my controller.. and display it there
EDIT I have return deferred.promise BUT it returns ONLY the first promise of the SERVICE function not myFunc, and i need the promise of myFunc
EDIT 2
Look also at Carson Drake's answer, it isn't anti-pattern!