Alireza Valizade Alireza Valizade - 1 month ago 8
Javascript Question

(change) in angular 2 not working

I want when user typing in input execute a function,like this :

<input
id="cell"
type="text"
name="cell"
ngControl="cell"
(change)="topersian($event)"
>

topersian($event){

$event.currentTarget.value = $event.currentTarget.value.toPersianNumber();

}


i dont want use
(keypress)
or
(keyup)
because user can see the english number.
i use
[(ngModelChange)]
but cant access to
$event
,just get value!
how to fix this problem ? or any body have A better solution?

Answer

Looks like Change event not firing on text input using jquery in Chrome

The input event should do what you want

<input (input)="topersian($event)>