Kri*_*rki 1 typescript ionic2 angular2-components ionic3 angular
这是一堂课
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);
}
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我如何从Anular 2或Ionic 3中的onsubmit回调函数调用funcB.
提前致谢.
使用箭头函数,它捕获以下值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);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1894 次 |
| 最近记录: |