I am using angularJs factory its making call and working as expected but in terms of exception i have question what if we have exception after making call and it fails so in this case when i execute prcDeleteFactory.deletePrcInventory i want to check first if there is any error display error and stay on same page.
How can i resolve this problem using below code ?
ctrl.js
function deleteInventory(inventory,controlId) {
prcDeleteFactory.deletePrcInventory(inventory,controlId).then(function(){
$scope.confirmationWin.close();
$state.go('app.search');
});
}
factory.js
angular.module('App').factory('prcDeleteFactory',function($http){
'use strict';
return {
deletePrcInventory: function(inventoryToDelete,key){
return $http.get('app/delete/deleteInventory?inventoryToDelete=' + inventoryToDelete + '&key=' + key);
}
};
});