How to check with Ionic if Phonegap/Cordova is ready?

How to check with Ionic if Phonegap/Cordova is ready?

I think with this code, but I don’t like to put a call into body onLoad.

Device Ready Example
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">

// Wait for device API libraries to load
//
function onLoad() {
    document.addEventListener("deviceready", onDeviceReady, false);
}

// device APIs are available
//
function onDeviceReady() {
    // Now safe to use device APIs
}

</script>

You can use $ionicPlatform.ready inside of a controller. See here.

1 Like