mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-01-19 08:32:52 +08:00
fix(ng1): use $q promises instead of the native Promise (#378)
This commit is contained in:
parent
5506e8a2e2
commit
817a4340e7
@ -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.');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user