Reputation: 5416
I want to use the LibraryHelper
plugin in my Ionic 2 app, but the docs for it defines its usage statically, e.g.:
LibraryHelper.saveVideoToLibrary(....)
NOT through:
window.plugins.LibraryHelper.saveVideoToLibrary(....
When I write the first line in my Typescript .ts file, I get the error:
Cannot find name 'LibraryHelper'
Q) How do I import the LibraryHelper plugin into my Ionic 2 app and be able to reference it without it - being undefined as above?
Upvotes: 3
Views: 538
Reputation: 29614
Make sure to install the plugin with the --save
option
ionic plugin add cordova-library-helper --save
You need to declare the global object LibraryHelper
in your class after your imports.
//imports
declare var LibraryHelper:any;
@Component({..})
//..
When you are using in your component, just make sure to wrap within
this.platform.ready().then(()=>{
LibraryHelper.saveVideoToLibrary(....)
})
Upvotes: 2