I am prototyping an A Hybrid Mobile app using Ionic + Angular + Apache Cordova 4.0 using Visual Studio 2003 update 4. I installed the SQLite plugin to access database.
Recommended method to access this plugin is:
var db = window.sqlitePlugin.openDatabase({name: "my.db"});
But I don't have typescript definition for plugin - only Cordova. SO Typescript does not know the sqlitePLugin and its complaining about it.
How do you access Cordova plugin from Typescript code ? I understand I have to somehow extend the basic "window" object ? How to do that ?
Thanks.
I understand I have to somehow extend the basic "window" object ? How to do that ?
Here you go:
interface Window {
sqlitePlugin: any;
}
var db = window.sqlitePlugin.openDatabase({name: "my.db"});
Note: TypeScript interfaces are open ended in that their declaration can be re-opened to add members.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With