Open
Description
I'm trying to handle a more graceful offline/timeout scenario for an app. The idea is to update the UI when a request fails with status 0 (i.e., api is offline or request timed out), and then once request is POST-ed to the server update UI with fresh data.
Here's the pseudo-code:
var a = new Article({text: 'we all try something'});
a.$save();
a.$promise.then(updateUI).catch(function(request) {
if (request.status == 0) {
// show an updated UI like "pending" status
updatePendingStatus();
}
});
// after a minute or two when the request is retried
// and submitted successfully, then update UI.
a.$httpPromise.then(updateUI);
However it seems a.$httpPromise
is undefined
. How do I achieve what I want?