Cordova插件没有使用ionic

时间:2022-05-12 19:50:19

I have an Ionic app built with Angular.

我有一个内置角的离子应用。

I am using is Calendar plugin: https://github.com/EddyVerbruggen/Calendar-PhoneGap-Plugin

我使用的是is日历插件:https://github.com/eddyverbruggen/calendar - phonegap插件

I want to create events through the plugin and save them to the local device's calendar.

我想通过插件创建事件并将它们保存到本地设备的日历中。

I have added the plugin though:

我已经添加了插件:

cordova plugin add https://github.com/EddyVerbruggen/Calendar-PhoneGap-Plugin.git

And I try to use it in my controller:

我试着在我的控制器中使用它:

 ionic.Platform.ready(function(){onError);
    window.plugins.calendar.createEvent(title, location, notes, start, end, onSuccess, onError);
 });

In the browser it says window.plugins is undefined and on the device the error is 'undefined' is not an object (evaluating 'window.plugins.calendar')

在浏览器中显示窗口。插件是未定义的,在设备上错误是“未定义”,不是对象(计算“window.plugin .calendar”)

I have searched high and low for this, I cant seem to find a solution that works.

我到处找过了,似乎找不到一个有效的解决办法。

Any idea how to use a Cordova plugin with Ionic?

你知道怎么用一个带有Ionic的Cordova插件吗?

2 个解决方案

#1


16  

The answer was to add

答案是补充

<script src="cordova.js"></script>

And rebuild the Platforms

和重建平台

If still issue not resolved, remove and add the platforms

如果仍然存在未解决的问题,则删除并添加平台

#2


8  

Cordova plugins only runs on emulators or real devices.

Cordova插件只在模拟器或真实设备上运行。

To test a Cordova app with the browser take a look also to Ripple Emulator (Chrome plugin), but I prefer to test on real devices.

要测试一个带浏览器的Cordova应用程序,也要看一下波纹仿真器(Chrome插件),但我更喜欢在真实设备上进行测试。

Cheers!

干杯!

#1


16  

The answer was to add

答案是补充

<script src="cordova.js"></script>

And rebuild the Platforms

和重建平台

If still issue not resolved, remove and add the platforms

如果仍然存在未解决的问题,则删除并添加平台

#2


8  

Cordova plugins only runs on emulators or real devices.

Cordova插件只在模拟器或真实设备上运行。

To test a Cordova app with the browser take a look also to Ripple Emulator (Chrome plugin), but I prefer to test on real devices.

要测试一个带浏览器的Cordova应用程序,也要看一下波纹仿真器(Chrome插件),但我更喜欢在真实设备上进行测试。

Cheers!

干杯!