I wrote some code for promise understanding:
function test1() {
return $http.get("google.com").then(function (data) {
console.log("OK1");
}, function (data) {
console.log("ERROR1");
});
}
$scope.test = function() {
test1().then(function (data) {
console.log("OK2");
}, function (data) {
console.log("ERROR2");
});
}
And when I try execute this I get ERROR 1 OK2
but I expect ERROR1 ERROR2
.
How understand that?
Full example: http://jsfiddle.net/HB7LU/14804/