[英]ionic/cordova cannot create plugin
i have problem with creation of my own plugin in ionic framework. 我在ionic框架中创建自己的插件时遇到问题。
This is my plugin.xml: 这是我的plugin.xml:
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="org.apache.cordova.hid" version="0.0.1">
<name>Hid</name>
<description>Cordova HID USB Plugin</description>
<license>Apache 2.0</license>
<keywords>cordova,hid</keywords>
<js-module src="www/hid.js" name="hid">
<clobbers target="hid" />
</js-module>
</plugin>
This is my hid.js file that contains testing code: 这是我的hid.js文件,其中包含测试代码:
var exec = require('cordova/exec');
var hid = {
testFunc : function(callback) {
callback('echo echo');
}
}
module.exports = hid;
I installed plugin to project using add: 我使用add将插件安装到项目中:
$ ionic plugin add ./hid-plugin
Updated the hooks directory to have execute permissions
Saving plugin to package.json file
Then it appeared in my project in plugins folder. 然后它出现在我的项目的plugins文件夹中。
This is my controllers.js: 这是我的controllers.js:
angular.module('starter.controllers', [])
.controller('DashCtrl', function($scope) {})
.controller('ChatDetailCtrl', function($scope, $stateParams, Chats) {
$scope.chat = Chats.get($stateParams.chatId);
// HERE IS THE TESTFUNC
hid.testFunc(function(echoValue) {
alert(echoValue);
});
});
And this results into an error: 这导致一个错误:
ionic.bundle.js:25642 ReferenceError: hid is not defined
at new <anonymous> (http://localhost:8100/js/controllers.js:23:5)
at invoke (http://localhost:8100/lib/ionic/js/ionic.bundle.js:17762:17)
at Object.instantiate (http://localhost:8100/lib/ionic/js/ionic.bundle.js:17770:27)
at http://localhost:8100/lib/ionic/js/ionic.bundle.js:22326:28
at self.appendViewElement (http://localhost:8100/lib/ionic/js/ionic.bundle.js:56883:24)
at Object.switcher.render (http://localhost:8100/lib/ionic/js/ionic.bundle.js:54995:41)
at Object.switcher.init (http://localhost:8100/lib/ionic/js/ionic.bundle.js:54915:20)
at self.render (http://localhost:8100/lib/ionic/js/ionic.bundle.js:56743:14)
at self.register (http://localhost:8100/lib/ionic/js/ionic.bundle.js:56701:10)
at updateView (http://localhost:8100/lib/ionic/js/ionic.bundle.js:62357:23) <ion-nav-view name="tab-chats" class="view-container tab-content" nav-view="active" nav-view-transition="android">
I tried almost everything: 我几乎尝试了所有事情:
but without positive result. 但没有积极的结果。
Can you point to me what I've missed or done wrong? 您能指出我错过或做错的事情吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.