Here is a class
export class ChatDetailPage {
constructor(){
}
funcA(){
var options = {
onSubmit: function (text) {
//i want to be able to access funcB from here
this.funcB(text)
},
this.nativeKeyboard.showMessenger(options)
}
funcB(text){
alert (text);
}
}
Here in this case how can i call funcB from onsubmit callback function in Anular 2 or Ionic 3.
Thanks in advance.
Use an arrow function, which captures the value of this
:
export class ChatDetailPage {
constructor(){
}
funcA(){
var options = {
onSubmit: text => {
//i want to be able to access funcB from here
this.funcB(text)
},
};
this.nativeKeyboard.showMessenger(options)
}
funcB(text){
alert (text);
}
}