patentul patentul - 11 months ago 113
Javascript Question

Ionic undefined plugin from cordova

I have an Ionic app and in the index.html file I have the following

<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>

<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js" async="false"></script>

<!-- your app's js -->
<script src="js/app.js" async="false"></script>
<script src="js/controllers.js" async="false"></script>
<script src="js/services.js" async="false"></script>

The issue is that in cordova.js I have a plugin that does get initialized only after the controllers.js file is downloaded and executed, thus if I want to use that plugin in the controllers I can't because of an undefined error.

How can I make the controllers, app and services scripts load only after the cordova.js script has been downloaded and executed?



Load it in this order

<script type="text/javascript" src="cordova.js"></script>
 <script src="ionic.bundle.js"></script>