mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-03-31 03:22:48 +08:00
29 lines
805 B
TypeScript
29 lines
805 B
TypeScript
declare var window;
|
|
|
|
/**
|
|
* Initialize the ngCordova Angular module if we're running in ng1.
|
|
* This iterates through the list of registered plugins and dynamically
|
|
* creates Angular 1 services of the form $cordovaSERVICE, ex: $cordovStatusBar.
|
|
*/
|
|
export function initAngular1(plugins) {
|
|
if (window.angular) {
|
|
window.angular.module('ionic.native', []);
|
|
|
|
for(var name in plugins) {
|
|
let serviceName = '$cordova' + name;
|
|
let cls = plugins[name];
|
|
|
|
(function(serviceName, cls, name) {
|
|
window.angular.module('ionic.native').service(serviceName, [function() {
|
|
let funcs = {};
|
|
for (var k in cls) {
|
|
funcs[k] = cls[k];
|
|
}
|
|
funcs['name'] = name;
|
|
return funcs;
|
|
}])
|
|
})(serviceName, cls, name);
|
|
}
|
|
}
|
|
}
|