fix(ng1): use $q promises instead of the native Promise (#378)

This commit is contained in:
Matt Lewis 2016-07-31 19:24:56 +01:00 committed by Ibrahim Hadeed
parent 5506e8a2e2
commit 817a4340e7

View File

@ -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.');
}