-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
22 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,28 @@ | ||
declare var window; | ||
|
||
/** | ||
* Initialize the ngCordova Angular module if we're running in ng1 | ||
* 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() { | ||
export function initAngular1(plugins) { | ||
if (window.angular) { | ||
window.angular.module('ngCordova', []); | ||
} | ||
} | ||
window.angular.module('ionic.native', []); | ||
|
||
/** | ||
* Publish a new Angular 1 service for this plugin. | ||
*/ | ||
export function publishAngular1Service(config: any, cls: any) { | ||
let serviceName = '$cordova' + cls.name; | ||
console.log('Registering Angular1 service', serviceName); | ||
window.angular.module('ngCordova').service(serviceName, [function() { | ||
let funcs = {}; | ||
for (var k in cls) { | ||
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); | ||
} | ||
return funcs; | ||
}]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters