Use a custom cordova plugin


#1

Hi,
I want to use this cordova plugin : https://github.com/xseignard/cordovarduino.
But I always have the same error : Error TS2304: Cannot find name ‘serial’.

I have added the plugin with : cordova plugin add cordovarduino

Do you have any ideas about this issue ?

I don’t from where I have to import serial ?

Thank you !


#2

Add this line to your ts file declare var serial; :

import {Component} from '@angular/core';

declare var serial;

@Component({
  templateUrl: './build/your-template.html'
})
export class yourPage { }

#3

And with that, can I use all the functions which are in the plugin ?
Thank you.


#4

Yes you can do it :wink:


#5

Amazing !!! Thank you very much !! Could you explain how it works ? How can I use all the function inside the plugin, just in declare a variable ?


#6

Hello,

does this work only in Components or in “service” classes too? I try to use cordova-plugin-zeep. I tried to declare $cordovaZeep. But it is always undefinied.

Thank you