When I get the set point which is written on a JSON file using a $resource, how is it settled? $promise of $resource don't have resolve function.
myApp.factory('prop', function($resource) {
return {
getSetting: function(key) {
var res = $resource('setting.json').query(); // *1
/* ? What is the processing here? */
return res[key];
}
}
});
update add write
res is resource object. res have $promise. At the time *1, res is not settled. I want to be settled in this function. What kind of processing should I add?
Is it like that?
myApp.factory('prop', function($resource) {
return {
getSetting: function(key) {
return $resource('setting.json').query().$promise.then(function(res) {
return res[key];
}
}
}
});
$resource return a resource object containing an attribute $promise. You can then on it.