i want all the data processing to be done in the service/factory and i just want to get the data back from it,
Currently what i am doing is like this:
.controller('homeCtrl', function($scope, companyFactory){
companyFactory.getNames().then(function(result){
//got the data
//do some processing and checks
})//then
})//controller
in my factory i have the following:
.factory('companyFactory', function($http) {
var myObject ={
getNames:function(){
var dataReq = {
method: 'POST',
url: 'somesite.com'
}
return $http(dataReq);
}//getnames
} //my object
return myObject;
})
This works fine but i want to do something like this.
.factory('companyFactory', function($http) {
var myObject ={
getNames:function(){
var dataReq = {
method: 'POST',
url: 'somesite.com'
}
$http(dataReq).then(function(){
//got the data
//do some processing and checks
//return the processed data
});
}//getnames
} //my object
return myObject;
})
How can this be done?