angular.module(‘starter’, [‘ionic’, ‘starter.controllers’])
.run(function($ionicPlatform,admobService) {
$ionicPlatform.ready(function() {
if (window.cordova && window.cordova.plugins.Keyboard) { cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); } if (window.StatusBar) { // org.apache.cordova.statusbar required StatusBar.styleDefault(); }
});
})
.factory(‘admobService’,function(){
var admobid = {};
if( /(android)/i.test(navigator.userAgent) ){ // for android
admobid = {
banner: ‘ca-app-pub-3815248714018431/123456’
};
}
return { createAdmobBanner: function(){ AdMob.createBanner({ adId:admobid.banner adSize: 'SMART_BANNER', position:8 }); } }
});
I want to call the createAdmobBanner function in my controllers but the plugin have to be run in the ionicPlatformReady in order to work, so I have to create a factory, but I got an error when try to injecting it into the run(), what the heck?