I'm new to Ionic and Cordova.
(我是Ionic和Cordova的新手。)
I need to create a plugin for ionic using Cordova and integrate it in sample ionic app. (我需要使用Cordova为ionic创建一个插件,并将其集成到示例ionic应用程序中。)
Steps I Followed are:
(我遵循的步骤是:)
Created a simple ionic plugin using plugman
(使用Plugman创建了一个简单的离子插件)
plugman create --name SayHello --plugin_id cordova-plugin-sayhello -plugin_version 0.0.1
Added android platform to above plugin.
(在上述插件中添加了android平台。)
cd SayHello/ && plugman platform add --platform_name android
Now I want to integrate this plugin into my ionic app.
(现在,我想将此插件集成到我的离子应用程序中。)
ionic cordova plugin add ../SayHello
In my ionic app inside Home.ts, I wrote this piece of code.
(在Home.ts中的离子应用程序中,我编写了这段代码。)
declare var cordova: any;
var success = function(result) {
console.log(result);
}
var failure = function(err) {
console.log(err);
}
cordova.plugins.HelloWorld.coolMethod("SayHelloTest", success, failure);
The problem is I cannot call any function from success or failure in the ionic app.
(问题是我无法从离子应用程序的成功或失败中调用任何函数。)
like if I call function doSomething from success:
(就像我成功调用函数doSomething一样:)
var success = function(result) {
doSomething(result);
}
It Shows Error doSomething function not found.
(它显示错误doSomething函数未找到。)
It can only print in console. (它只能在控制台中打印。)
ask by Saurabh Pandey translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…