Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the equivalent of Angular's $q in Angular2?

Tags:

What's the equivalent of Angular's $q in Angular2? Specifically, I'm looking for $q.when, which allowed you to do something like:

return $q.when(['TestResponse']); 
like image 570
David Avatar asked Jun 09 '16 07:06

David


1 Answers

new Promise((resolve, reject) => {    if(xxx) {     resolve('ok');   } else {     reject('error');   } }).then(x => doSomething()) 

See also https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise or http://learnangular2.com/es6/promises

like image 127
Günter Zöchbauer Avatar answered Sep 28 '22 00:09

Günter Zöchbauer