angular-promise-polyfill
Version:
Use angular $q as global Promise polyfill
41 lines (28 loc) • 917 B
Markdown
using angular $q service.
```npm install angular-promise-polyfill```
Then just include this module to your project and add to main Angular app dependencies.
```javascript
require('angular-promise-polyfill');
let app = angular.module('myApp', [promisePolyfill, ...]);
// Now you can use Promise anywhere
var promise1 = new Promise((resolve, reject) => {
setTimeout(() => {
resolve('second');
}, 2000);
});
var promise2 = new Promise((resolve, reject) => {
setTimeout(() => {
resolve('first');
}, 1000);
});
Promise.race([promise1, promise2])
.then((result) => {
//Logs 'first'
console.log(result);
})
```
Original answer from [Rob / robianmcd](https://gist.github.com/robianmcd) (https://gist.github.com/robianmcd/8f04507acd014b57b95a)
Thanks man! =)
This module provide Promise support via