In my device’s system log using the console plugin. I got the “Device Ready” log, but no “App Ctrl Loaded”. I assumed then that the controllers are loaded before cordova is actually ready. Is this assumption correct?
Hey @seanhill. There isn’t necessarily a connection between controller load time and deviceready firing. That event comes from the Cordova internals, and if you set the listener too late, the event will have already fired and you’ll miss it.
To deal with this, we’ve given you the Platform service, which you can use to always call a function when the device is ready (or after if it’s already been loaded):
You have to bootsrap AngularJS by yourself.
First remove the ng-app directive from your index.html. Then attach an event listener to your document ready and deviceready event. After that two events are fired you can bootstrap angular manually:
var ngDocument = angular.element(document);
angular.element(ngDocument).ready(function() {
ngDocument.on('deviceready', function() {
var body = ngDocument.find('body');
angular.bootstrap(body, ['myApp']);
});
});
var myApp = angular.module('myApp', []);
If you make it like this it is guaranteed that all cordova plugins are loaded before Angular initializes his services, controllers and so on.
I’ve been looking for this since morning!
The select queries of sqlite database did not come to the page using ng-init. because the page was loading first did not see the database. I used this code to run the platform ready before the controller so the database was open.