# Wait $ionicPlatform.ready response before init controller

**URL:** <https://forum.ionicframework.com/t/wait-ionicplatform-ready-response-before-init-controller/8072>\
**Category:** ionic-v1\
**Created:** [August 11, 2014, 6:26pm UTC](https://forum.ionicframework.com/t/wait-ionicplatform-ready-response-before-init-controller/8072 "2014-08-11T18:26:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tibz](https://avatars.discourse-cdn.com/v4/letter/t/e68b1a/32.png) [@Tibz](https://forum.ionicframework.com/u/Tibz)\
**Post date:** [August 11, 2014, 6:26pm UTC](https://forum.ionicframework.com/t/wait-ionicplatform-ready-response-before-init-controller/8072/1 "2014-08-11T18:26:31Z")

</div>

Hello people,  
Sorry for by bad english, i’m a french developer 🙂 ([www.tibz.net](http://www.tibz.net))  
i’m currently making an IOS mobile application with Ionic and i’ve got a little problem with first initialization.  
I work with the **sidemenu template** from the beginning, my first controller is init from the

```
$urlRouterProvider.otherwise('/app/mycontroller'); 

```

In my first controller (my main rub), i need use **$cordovaNetwork** and **other cordova plugin** (ng-cordova is great guy!), to do this, **i must wait a $ionicPlatform.ready response.**  
I already listen this event on app.js in the run method.

```
angular.module('vttapp', ['ionic','ngCordova','vttapp.controllers', 'vttapp.services','vttapp.utils'])
.run(function($ionicPlatform) {

 $ionicPlatform.ready(function(){
 // todo
 });

}).config..........

```

I want wait this event and only after initialise my first controller, i wan’t use the

```
$urlRouterProvider.otherwise('/app/mycontroller')

```

who initialise my controller before event is dispatched.  
It’s possible it’s a tips about Angular (i’m newbie with), Thanks for your answers anyway!

I could wait a $ionicPlatform.ready directly from my first controller, but i want really do intialisation outside of my controller ($ionicPlatform.ready dispatch only one time)

Thanks !

---

<div class="post-metadata">

**Author:** ![novnip](https://avatars.discourse-cdn.com/v4/letter/n/ce73a5/32.png) [@novnip](https://forum.ionicframework.com/u/novnip)\
**Post date:** [August 23, 2014, 12:51pm UTC](https://forum.ionicframework.com/t/wait-ionicplatform-ready-response-before-init-controller/8072/2 "2014-08-23T12:51:50Z")

</div>

Hi! Sorry for my english, i’m russian developer =)  
Did you solve this problem? I have the same problem, can you say your solution?

---

<div class="post-metadata">

**Author:** ![twinssbc](https://avatars.discourse-cdn.com/v4/letter/t/9de0a6/32.png) [@twinssbc](https://forum.ionicframework.com/u/twinssbc)\
**Post date:** [April 25, 2015, 12:43pm UTC](https://forum.ionicframework.com/t/wait-ionicplatform-ready-response-before-init-controller/8072/3 "2015-04-25T12:43:21Z")

</div>

I also met this problem recently.  
One way is to subscribe the deviceready event and manually bootstrap the app.

> <https://stackoverflow.com/questions/22081180/initialize-my-angularjs-app-after-phonegap-deviceready>

But in my app I need to make sure the sqlite plugin is initialized and the database is opened successfully.  
My current solution is first navigate to a loading page, when all the initialization logic is done in the $ionicPlatform.ready method, navigate to the first functional page.

---

<div class="post-metadata">

**Author:** ![lolaswift1](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/lolaswift1/32/115280_2.png) [@lolaswift1](https://forum.ionicframework.com/u/lolaswift1)\
**Post date:** [June 6, 2017, 8:50pm UTC](https://forum.ionicframework.com/t/wait-ionicplatform-ready-response-before-init-controller/8072/4 "2017-06-06T20:50:18Z")

</div>

@twinssbc, Probably, you’d never expect that after two years, your reply still could save someone else’s day.  
You saved my day. thank you!  
I don’t use sqllite but I need to achieve something similar. ui-router for angular 1.x isn’t so straingforward in terms of handling async authentication. using a loading page allows me to get data ready before transiting to a route which requires authentication. I’d tried so many methods before I read your reply. None worked as what I expected. You solution isn’t an elegant one but the most important thing is , it works in my case.
