Using $ionicPlatform.ready() in module.js before plugins are initialized #8
Comments
This is a must imho, but I would use a "deviceready" event instead of $ionicPlatform.ready(). |
Yeah, "deviceready" would be cool! |
+1 |
Ah I killed last two hours trying to figure out why this isn't working... then I tried to wrap it all with timeout for 5s and wuala... Until your suggestion will be in the official cordova api what do you guys think is the cleanest way to solve my situation please ?
|
I believe the
The problem is
Make sure to put the I am wondering if there is a better way to detect |
We should add a separate, non ionic-prefixed thing here. It's okay if they overlap since they will both fire correctly. Maybe something like $cordova.ready(function() {
}); |
Yeah something as an overall "umbrella" prior to loading angular modules would work. So that there is no |
An another way is to initialize angular dynamically when cordova is ready.
Works like a charm. |
Hey @Natsu- how does this behave when developing in a browser? Cordova ready is not fired while in a browser. Does it still bootstraps the app? |
Yes, app is also bootstrapped in a browser.
|
Hi @Natsu- , I tested your approach. Works good in browsers. But on iOS it fails - ending up with a white screen. I removed the ng-app directive from the body tag and bootstrapped it like you said within the Platform.ready .. |
Do you have some error logs ? On XCode / Safari web inspector ? |
There were no errors shown within the console. But now I wrapped that into a try- block and catched the exception with an alert so I found out that the error was the following:
in app.js
As soon as I removd the Keyboard-Plugin lines it starts working.. so I double checked the installed plugins and found out that for any reason I don't now the keyboard plugin was not configured anymore in the Afer reinstalling the Plugin it now works.
Thanks @Natsu- for your approach. Works perfectly for me now. |
Well done ! |
I was able to use the
|
Then you still have to check for the |
@quanghoc Perhaps I'm missing something but the promise returned from the |
Oh I think you're right. We must state to the users this solution require the use of ui-router |
@natsu perfect approach! |
A new WIP is happening @ #386. Would love to hear your thoughts and comments |
Changed the install link back to the original author, after acceptance of pul request ionic-team#8 on the master branch of phonegap-plugin-brightness.
Any news about this ? Adding the "ready" condition to the plugins ? |
Same as @JerryBels, there is any news about it? |
+1 ? |
@pbernasconi blogged about adding this on the Ionic blog back in December 2014, but it's still hasn't been added. Would love to hear some news. |
+1 to what @simpixelated said |
+1 for @emertechie abstract view suggestion |
+1 |
Here's a nice work around I found for this recently: |
I've wasted hours here, why would all the examples show ,
If none of the plugins are loaded on $ionicPlatform.ready ? when my app starts I need to register notifications, I do this on run and use $ionicPlatform.ready - but I'm seeing the behavior where where window.cordova isn't defined |
I used @romgar's solution posted here. #8 (comment) |
@emertechie thanks for the code! $routeProvider
.when('/', {
templateUrl: 'views/home.html',
controller: 'homeController',
resolve: {
cordova: function($q) {
var deferred = $q.defer();
document.addEventListener("deviceready", function () {
console.log('ionic.Platform.ready');
deferred.resolve();
});
return deferred.promise;
}
}
}) |
Thanks @romgar, it works for me too. |
pbernasconi commentedJun 2, 2014
What do you think about returning a promise in the module which uses
$ionicPlatform.ready()
to make sure the plugins are not used until the dom is ready?Then each plugin uses the
ngCordova
service service like so:The text was updated successfully, but these errors were encountered: