Skip to content

Instantly share code, notes, and snippets.

@tomgullo
Last active December 17, 2015 10:18
Show Gist options
  • Save tomgullo/5593410 to your computer and use it in GitHub Desktop.
Save tomgullo/5593410 to your computer and use it in GitHub Desktop.
angular_js_promise.js
$scope.getFakeStuff = function() {
timeoutTest(1)
.then(timeoutTest)
.then(timeoutTest)
.then(function(data) {
console.log("done " + data);
}, function(reason) {
console.log("error " + reason);
})
;
}
var timeoutTest = function(data) {
console.log("passed in data " + data);
var deferred = $q.defer();
$timeout(function() {
// if (data == 2) {
// deferred.reject("data is 2");
// } else {
deferred.resolve(data + 1 );
// }
}, 1000);
return deferred.promise;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment