How can i pass class variable inside the Alert Controller Button Handler. I tried to use the class varibales inside but the are undefined.
class BluetoothPrinterPage {
unpairedDevices: any;
pairedDevices: any;
gettingDevices: Boolean;
constructor(public navCtrl: NavController, public navParams: NavParams, private bluetoothSerial: BluetoothSerial, private alertCtrl: AlertController, public viewCtrl: ViewController) {
bluetoothSerial.enable();
}
disconnect() {
let alert = this.alertCtrl.create({
title: 'Disconnect?',
message: 'Do you want to Disconnect?',
buttons: [
{
text: 'Cancel',
role: 'cancel',
handler: () => {
console.log('Cancel clicked');
}
},
{
text: 'Disconnect',
handler: () => {
this.bluetoothSerial.disconnect();
}
}
]
});
alert.present();
}
}
But here inside the handler this.bluetoothSerial is undefined.