How to get local ip in Ionic 2?

Viewed 1616

i have a problem with ionic 2 and cordova plugin network interface, i already install the plugin and in home.ts i declared a variable with the same name, type any, for get ip address, i see the tutorial of that plugin in github, but in my app doesn't works, can you help me?

home.ts:

declare var networkinterface:any;
@Component({
selector: 'page-home',
templateUrl: 'home.html',
providers: [NodeProvider]
})
export class HomePage {
 public ip = "";

constructor(public navCtrl: NavController, public loadCtrl:   LoadingController, public nodeProvider: NodeProvider, public alertCtrl: AlertController) {

}

ionViewDidLoad(){
networkinterface.getIPAddress(function (ip) {
    console.log((ip));
});

}

And errors ionic throws me:

Ionic error

0 Answers
Related