Skip to content

Instantly share code, notes, and snippets.

@yngvebn
Last active November 7, 2015 13:48
Show Gist options
  • Save yngvebn/f716fd42332aef113a0a to your computer and use it in GitHub Desktop.
Save yngvebn/f716fd42332aef113a0a to your computer and use it in GitHub Desktop.
function startPromise(){
var promise = $q.defer();
var i = 0;
$interval(function(){
i++;
promise.notify(i);
if(i === 10){
promise.resolve(i);
}
}, 500);
return promise.promise;
}
startPromise().then(
function(data) { console.log('resolved '+data)},
function(data) { console.log('rejected '+data)},
function(data) { console.log('progress '+data)})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment