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

廉价感情. 提交于 2019-12-01 02:14:21
Günter Zöchbauer
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

You can use the native es6 Promise. One of the main reason to make new angular is es6 and nearly comming es7.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!