This is my initial angular function. I am setting whrong http address and working http address, but working then function in any case. If I set wrong http address it sholud be handle catch function. This is working demo.
(function () {
loadAppSettings().then(function () {
alert(1)
}).catch(function(){
alert(0)
});
function loadAppSettings() {
var $http = angular.injector(["ng"]).get("$http");
return $http.get("oops").then(
function (response) {
angular.module("app").constant("appSettings", response.data);
}
).catch(
function (errorResponse) {
console.error("app settings couldn't load.")
}
);
}
})();
catchfunction working always. If you remove catch from loadAppSettings thenalert(0)will works fine. fiddle