我想当用户输入时执行一个函数,像这样:
<input
id="cell"
type="text"
name="cell"
ngControl="cell"
(change)="topersian($event)"
>
topersian($event){
$event.currentTarget.value = $event.currentTarget.value.toPersianNumber();
}
我不想使用 (keypress)
或 (keyup)
因为用户可以看到英文数字。
我使用 [(ngModelChange)]
但无法访问 $event
,只是获取值!
如何解决这个问题?或者有人有更好的解决方案吗?
最佳答案
看起来像Change event not firing on text input using jquery in Chrome
input
事件应该做你想做的事
<input (input)="topersian($event)>
关于javascript - Angular 2 中输入的更改事件不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37775026/