Skip to content

Commit

Permalink
fix(ng1): use $q promises instead of the native Promise (#378)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattlewis92 authored and ihadeed committed Jul 31, 2016
1 parent 5506e8a commit 817a434
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ function callCordovaPlugin(pluginObj: any, methodName: string, args: any[], opts
}

function getPromise(cb) {
if (window.Promise) {
return new Promise((resolve, reject) => {
cb(resolve, reject);
});
} else if (window.angular) {
if (window.angular) {
let $q = window.angular.injector(['ng']).get('$q');
return $q((resolve, reject) => {
cb(resolve, reject);
});
} else if (window.Promise) {
return new Promise((resolve, reject) => {
cb(resolve, reject);
});
} else {
console.error('No Promise support or polyfill found. To enable Ionic Native support, please add the es6-promise polyfill before this script, or run with a library like Angular 1/2 or on a recent browser.');
}
Expand Down

0 comments on commit 817a434

Please sign in to comment.