Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular ngModelChange Internet Explorer 11

I use Angular 4.2.4 and Angular Material 2.0.0.beta.12 and have following form field:

<mat-form-field>
    <input matInput placeholder="street" value="{{info.street}}" [(ngModel)]="info.street" (ngModelChange)="formChange()">
</mat-form-field>

In Firefox and Chrome everything works as it should and an events fires if I change the input value. But in Internet Explorer 11 everytime the site loads or if I focus the input field the ngModelChange is fireing.

Is there a way to solve this issue? (change) is working but only fires if I focusout the input what is not practicable.

like image 810
Grobanix Avatar asked Oct 18 '25 18:10

Grobanix


1 Answers

I found out that placeholder attribute is what makes a difference in Internet Explorer. Without it ngModelChange works as expected.

The workaround for this case is to put the placeholder in square brackets :

 [placeholder]="'placeholder value'"

I assume that the placeholder is appended to the input element later (after IE processes it) and that's why IE doesn't fire ngModelChange event.

like image 183
JSimo Avatar answered Oct 20 '25 08:10

JSimo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!