Ionic.bundle.js causes onDeviceReady to be called twice on WP8


I have created an application using ionic for android and ios, and its working fine, but now i am trying to get it too work on WP8. it seems that if i exclude the ionic.bundle.js file, my deviceReady event gets called once. But if i include the ionic.bundle.js file, it gets called twice?

Anyone had experience with this? I thought i would test it by including the files individually, but not sure what to include and what to change in my app configuration.

I need to bootstrap the app with angular, and i am doing this via the deviceReady event, here is my code.

angular.module('myApp', [

.config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider) {

.run(function (AppData) {
    console.log(".run() called");

    // run some cordova plugins here


// manually bootstrapping angular, once deviceReady event has been called
function onDeviceReady() {
    console.log("onDeviceReady() called");

// bootstrap angular
angular.bootstrap(document.body, ['m2iAnywhere']);

document.addEventListener("deviceready", onDeviceReady, false);

Currently i just include the following ionic files on my index.html page

<script type="text/javascript" src="lib/ionic/js/ionic.bundle.min.js"></script>
<script type="text/javascript" src="lib/ngCordova/ng-cordova.js"></script>

My contents of my index.html page are

    <ion-nav-bar class="nav-title-slide-ios7 bar-positive">

    <ion-nav-view animation="slide-left-right">
        <!-- Center content -->

Can someone shed some light on this for me please?

oh, i am using the latest version - beta8


You shouldn’t have to manually bootstrap angular, as ionic.bundle takes care of that whole process already. Also, why is cordova included after ng-cordova?

Right now WP8 support is still a WIP, so not everything is stable for that platform.


Reason i manually bootstrap is because, i need to call my sqlite init() function to setup my database upon deviceReady, also this needs to be done before my homeController runs because it checks for records in the sqlite database and if there are no tables, then it will error.

Therefore in deviceReady, i call my database init function, to make sure my tables are setup, then manually bootstrap angular. Now when my homeController runs, the tables will be there, so no errors thrown.

Is this not the way to go about it?


Have you seen this?

This wrapper for the cordova sqlite plugin should help you work with DBs and have it play well with cordova/ angular.

This should help you not have to manually bootstrap the whole process.