Reputation: 1036
I have factory looks like this:
MyApp.factory("Hello", function(Restangular, $q){
var theConfig = function() {
var deferred = $q.defer();
Restangular.one('AllSettings').get().then(function(data){
var theData = return {
config1: data.config1,
config2: data.config2
}
deferred.resolve(data);
});
return deferred.promise;
};
return{
config : theConfig()
};
});
I already using deffered, but it's still not return the object that needs to execute. How to work around this?
Upvotes: 0
Views: 1452
Reputation: 1425
What you are returning is a promise, not the actual data passed into deferred.resolve
. Are you accessing the data like this?
MyApp.controller('WhateverController', function(Hello) {
Hello.config.then(function(data) {
// Do something with the data passed to deferred.resolve
});
});
Upvotes: 1