When using the deferred method offered by angularjs and querying the database local storage, the “resolve” doesn’t seem to work. See the following example. The “then” action is never fired.
When trying with a setTimeout instead of the “Person.all()” instruction, it works.
var defer = $q.deferred();
Person.all().list(null, function (persons) {
defer.resolve(persons);
});
defer.promise.then(function (persons) {
console.log('resolved');
});
Thanks for helping.
For Angularjs’s promise,
thenonly fires in digest cycle.If your
Personobject is in your service, you can inject$rootScopeandcall
$apply()against it to letthenfire.