I need a filter where i need to make $http call and then return that response . i am trying to use angular promise but nothing works . Return is not waiting for the response . Take a look below for my code. It is returning {} , Not waiting for $http response. I need this using filter only. Idea is to keep it separate from Controller , so it can be used anywhere later.
.filter('filterXML',['testOne','$sce',function(testOne, $sce){
return function(url){
return testOne.getTest(url).then(function(data){
return data;
});
}
}])
.factory('testOne', ['$http', function($http){
return {
getTest: function(url){
return $http.get(url).success(function(data){
console.log(data)
return data;
})
}
}
}])
Goal : {{ 'http://rss.cnn.com/rss/cnn_topstories.rss' | filterXML}}
So it will return all data from this rss feed .
I don't want to use controller . Idea is to make separate module and call it anywhere in application .
Any help will be appreciated . Thanks