Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jul 31, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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