Custom Plugin got undefined

I’m implementing a custom plugin for my ionic2 app,
I have created custom plugin using plugman, also added platform and installed it for that platform.

But now when i’m trying to call that plugin it throws error.

My code:

import { Component } from ‘@angular/core’;
import { Platform } from ‘ionic-angular’;
import { StatusBar } from ‘@ionic-native/status-bar’;
import { SplashScreen } from ‘@ionic-native/splash-screen’;

import { HomePage } from ‘…/pages/home/home’;
@Component({
templateUrl: ‘app.html’
})
export class MyApp {
rootPage:any = HomePage;

constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
statusBar.styleDefault();
splashScreen.hide();
cordova.plugins.CustomPrint.coolMethod(“Hello”, function(success) {
console.log(“plugin works”);
},
function(error) {
console.log(“error”)
}
);
});
}
}

And i’m getting error:
typescript: src/app/app.component.ts, line: 20
** Cannot find name ‘cordova’.**

** cordova.plugins.CustomPrint.coolMethod(“Hello”, function(success) {**
** console.log(“plugin works”);**
** },**

[17:05:05] build finished in 3.61 s

Typescript Error
Cannot find name ‘cordova’.
src/app/app.component.ts
cordova.plugins.CustomPrint.coolMethod(“Hello”, function(success) {
** console.log(“plugin works”);**
},

Add above @Compoment
declare var cordova: any;

2 Likes

yah i’ve solved it.
it was declare var cordova: any;
Just because of work stress i’ve ignored that small point but after one cup of coffee i’ve solved it:sweat_smile: