javascript - 如何在 $ionicplatform.ready 中引用 cordova 插件?
问题描述
因此,我使用 cordova plugin add cordovaarduino 添加了 cordovaarduino 插件,它位于插件目录中。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title></title>
<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
<link href="css/ionic.app.css" rel="stylesheet">
-->
<!-- 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"></script>-->
<!-- your app's js -->
<script src="js/app.js"></script>
</head>
<body ng-app="starter" ng-controller="hostController">
<div class="offline-outer-wrap">
<h2>Something Setup</h2>
<div class="offline-wrap">
<p>Something</p>
....
</div>
</div>
</body>
</html>
应用程序.js
app.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
if(window.localStorage['host']){
window.open('file:///android_asset/www/app/offline/index.html#device/android','_self')
}
});
});
在 $ionicplatform.ready() 中,window.cordova 不可用,我也无法使用导航器对象访问我的插件。
我怎样才能访问插件,我做错了什么?取消注释cordova.js文件给了我这个错误:提示错误“localhost:8100说gap_init:3”消息同时在浏览器中加载离子项目 但在android设备上
解决方案
推荐阅读
- r - 如何为求和创建一个 R for 循环?
- c# - '#if DEBUG' 和 '#endif' 如何删除两个标记之间的内容
- ajax - onchange 使用 ajax、codeigniter、下拉菜单、启用 CSRF 令牌
- flutter - 为什么不能将 Circle Avatar 识别为领先:在 ListTile 内?
- android - 如何使用 ADB 或以编程方式更改显示分辨率?
- angular - 获取访问令牌
- batch-file - 批处理脚本语言;网址以双引号开头
- java - 使用 Java swing 等待事件
- apache-kafka - kafka中的partitions参数是什么意思?
- javascript - 从另一个文件更改 Javascript 变量值