How to only use Dependencies in Controllers (E.g. NgCordova) when the App is ready?


#1

Hi,

My app uses ngCordova in one of the Controllers linked to my first page (ie. it is invoked when the first page is shown).

It seems to be the case that the app is trying to use ngCordova before it has been initialised - e.g. when the first page is shown I immediately try to locate the user’s location using:

$cordovaGeolocation.getCurrentPosition()

this sometimes fails in my simulator and sometimes does not. If I write out to the debug console I can see that the controllers are firing before my

$ionicPlatform.ready(function() {
    console.log('ionicPlatform.ready');

event. How do I tell the controllers not to be invoked until the platform is ready?

Thanks


#2

Hmm - I found this thread which discusses the problem is a fair bit of detail - When are the angular controller's loaded?

Will have to wrap my services in the $ionicPlatform.ready(function() { check I think