Can you explain the distinction between promise 1 and promise 2? The first one only has a $$state property, while the second one also includes error and success callbacks. What makes them different?
<div ng-app="app">
<div ng-controller="TodoCtrl">
</div>
</div>
angular.module('app', [])
.controller('TodoCtrl', function ($scope, $http) {
//promise 1
console.log('p1',$http.get("/echo/json/").then(
function(){ console.log('s1',arguments); },
function(){ console.log('e1',arguments); }
)
);
var p = $http.get("/echo/json/");
//promise 2
console.log('p2',p);
p.then(
function(){ console.log('s2',arguments);},
function(){console.log('e2',arguments);});
}
);
When checking the console log:
p1 Promise { $$state: Object }
$$state: Object
__proto__: Object
p2 Promise { $$state: Object }
$$state: Object
error: (fn)
success: (fn)
__proto__: Object