在应用程序运行期间,这就是我得到的:
Uncaught ReferenceError: cordova is not defined
ionic-core.js:466 Ionic Core: init
ionic-core.js:145 Ionic Core: searching for cordova.js
ionic-core.js:149 Ionic Core: cordova.js has already been loaded
现在这让我感到困惑,但我认为Ionic正在尝试在定义之前加载cordova。但是,这阻止了我使用依赖于这种情况的其他服务,所以我的问题是,有没有办法加载cordova异步或者还有什么可能是我的问题?
的index.html
<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>
<script src="lib/angular-websocket/angular-websocket.js"></script>
<script src="lib/ionic-service-core/ionic-core.js"></script>
<script src="lib/ionic-service-push/ionic-push.js"></script>
<script src="lib/facebook-connect-plugin/index.js"></script>
<!-- your app's js -->
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
<script src="js/services.js"></script>
<script src="js/utils.js"></script>
<!-- cordova script (this will be a 404 during development) -->
<script src="lib/ngCordova/dist/ng-cordova.min.js"></script>
<script src="cordova.js"></script>
答案 0 :(得分:4)
ng-cordova
使用cordova,因此必须稍后加载:
<script src="cordova.js"></script>
<script src="lib/ngCordova/dist/ng-cordova.min.js"></script>
答案 1 :(得分:1)
cordova的插件专为原生平台设计。因此,在浏览器中运行离子将使所有插件失败。这就是故事。