How to Deviceready in right way in Ionic application?

前端 未结 2 1046
轮回少年
轮回少年 2020-12-10 14:53

I have Cordova and Ionic based mobile application. On the default page which is loaded after the start of the application is need to work with SQLLite plugin.

https

相关标签:
2条回答
  • 2020-12-10 15:19

    I couldn't make it work with the @t4deu solution, because my ng-app tag was in the body, so I leave a little change in case that it helps to someone.

      <script>
        document.addEventListener('deviceready', function() {
          angular.bootstrap(document.querySelector('body'), ['starter']);
        }, false);
    
      </script>
    
    0 讨论(0)
  • 2020-12-10 15:36

    You need to invert this, first you handle the cordova "deviceready" event and then you start the angularjs app. Like this:

    1. First remove the the ng-app attribute from the html/body tag

    2. Start the angular app after the devireready:

      <script>
        document.addEventListener('deviceready', function() { 
          angular.bootstrap(document, ['YourAppName']);
        }, false);
        var YourAppName = angular.module('YourAppName', []);
      </script>
      

    Similar questions:

    • Cordova + Angularjs + Device Ready
    • Initialize my angularJs App after Phonegap deviceready
    0 讨论(0)
提交回复
热议问题