$ionicPlatform.ready() Where can i read about on doc?


#1

Ionic framework forum === The most active framework.!!

Where can i read about $ionicPlatform.ready() in doc or somewhere else?


#2

There isn’t a whole lot to it. If you go in the Ionic source could, you can see that it is just listening for the Cordova/phonegap deviceready event to fire.

  function onCordovaReady() {
    // the device is all set to go, init our own stuff then fire off our event
    ionic.Platform.isReady = true;
    ionic.Platform.detect();
    ionic.trigger('platformready', { target: document });
    document.removeEventListener("deviceready", onCordovaReady, false);
  }

This is in /ionic/js/utils/platform.js


#3

Thank’s Calendee… I understand…


#4

I just put together a platform docs page here: http://ionicframework.com/docs/angularjs/utils/platform/


#5

I try to do a mix of your link and:

So i try:

angular.module('starter.controllers', ['ionic'])
.run(function(ionic) {
  ionic.Platform.ready(function(){
            console.log('platform ready');
  })

But I have:
Uncaught Error: [$injector:modulerr]

What’s the best practise to call ionic.Platform.ready


#6

Not sure about “best practice”, but I use an overall “app” controller and put it there:

angular.module('app.controllers').controller('AppController', [ '$scope', '$ionicPlatform', function($scope, $ionicPlatform){

    // Identify the country code for this device
    $ionicPlatform.ready(function() {

	    console.log('platform Ready!');
	};

});

#7

Not sure either for “best practice” but we use a factory (in a configuration Module with other constants defined)

.factory(‘configFactory’, [’$ionicPlatform’,
function($ionicPlatform) {

          $ionicPlatform.ready(function() {

          });
          return $ionicPlatform.ready;

}])


#8

Funny that it’s called docs/angularjs/page but on that specific page you made @adam not a single word is spoken about the AngularJS service implementation, only the core Ionic javascript code :smile:

Of course any well-thinking human being is able to derive some information from that docs page, but the URL is kind of misleading; I was expecting AngularJS information there :wink:


#9

I am using $ionicPlatform.ready() in my main controller and I am seeing inconsistent behavior, sometimes the app loads and other times it doesnt. It is as if the ready callback is not always called.

This is on IOS


#10

Will be cleared up very soon with the new generated documentation.


#11

not really sure what this response means? I read through the latest release notes and there was nothing specific that spoke to the issue I am seeing.


#12

What I meant is we are working on source-generated documentation and are hoping to release it within the next few days. It will make everything much clearer.


#13

Is there any difference between

ionic.Platform.ready(function(){
    console.log('ionic platform ready');
});

and

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

#14

can I call function of first controller function from .run( onready function)


#15

dont inject ionic in .run function