As you know, Cordova fires the event ‘deviceready’ when it’s fully loaded. I want to use that event to run a function in which I can execute the plugins safely. Can I simply add this in each controller (each of my views have a seperate controller)? Is it a good idea to listen in each view to the same event? What’s the best practice?
angular.module('myapp.controllers')
.controller('CtrlOne', function($scope) {
// Listen for Cordova's ready
document.addEventListener('deviceready', onCordovaReady, false);
function onCordovaReady() {
// Run plugins
}
});
I’m aware of Ionic’s $ionicPlatform.ready(...);
function. But since it gets also triggered when running the app in a browser, I get errors because the plugins are not loaded (obviously).
Thanks for your help and expertise!