From 817a4340e76233f4e8953880acd991f6126ea5a0 Mon Sep 17 00:00:00 2001 From: Matt Lewis Date: Sun, 31 Jul 2016 19:24:56 +0100 Subject: [PATCH] fix(ng1): use $q promises instead of the native Promise (#378) --- src/plugins/plugin.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plugins/plugin.ts b/src/plugins/plugin.ts index 7d40780f5..a1b2cbc1a 100644 --- a/src/plugins/plugin.ts +++ b/src/plugins/plugin.ts @@ -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.'); }