I am used to using $q
with angular 1. I am migrating to angular 2.
Is there an equivalent that provide a .when()
method ?
for example I need to migrate this:
.service('updateProDB', [
'$rootScope',
'connectionStatus',
'$q',
'storageService',
'sendToServer',
'$ionicPopup',
function ($rootScope, connectionStatus, $q, storageService, sendToServer, $ionicPopup) {
'use strict';
var dbReadyDeferred = $q.defer(),
prodata = [],
prodataFieldNames = [];
this.get = function () {
var debugOptionUseLocalDB = 0,
prodata = [],
serverAttempts = 0;
if (debugOptionUseLocalDB) {
return fallbackToLocalDBfileOrLocalStorageDB();
}
if (connectionStatus.f() === 'online') {
console.log("Fetching DB from the server:");
return getDBfileXHR(dbUrl(), serverAttempts)
.then(function () { // success
console.log('-normal XHR request succeeded.');
return dbReadyDeferred.promise;
})
.catch(function (){