[英]How to call a function from Textchange event in typescript/nativescript
I'm trying to call a function to update a variable based on TextField input.我正在尝试调用一个函数来更新基于 TextField 输入的变量。
I may be missing something in the documents, but I can't figure this out.我可能在文件中遗漏了一些东西,但我无法弄清楚。
This is my XML这是我的 XML
<StackLayout class="p-20">
<Label text="{{_message}}" class="h2 text-center" textWrap="true" />
<TextField text="target" hint="Target" textChange="updateTarget" />
</StackLayout>
This is the main-view-model.ts这是主视图模型.ts
updateTarget(_target: string) {
console.log("Updating target: ${this._target}")
this.message = `Target: ${this._target}`
}
The updateTarget function isn't being called at all, I've tried extensive googling, but nothing seems to work.根本没有调用 updateTarget 函数,我尝试了广泛的谷歌搜索,但似乎没有任何效果。
<TextField text="target" hint="Target" textChange="{{updateTarget}}" />
<TextField text="target"hint="Target" (change)="function()" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.