0

I am developing new page in angular 6 application. I am trying to get the value of the current input from the 'change' event will be triggered.

My issue is that: The change event of an input has no data it just has "isTrusted" parameter !

Off-course when i am trying to get any other parameter (i.e. event.value, event.target ...etc.) it is giving me undefined.

Component HTML template & function :

 <div *ngFor="let items of item>
      <input type="text" id="{{item.id}}" (change)="dummyFunc($event)">
</div>

=======

dummyFunc(eve){
  console.log("dummy change .. "+JSON.stringify(eve));
}

output from dummyFunc is :

dummy change .. {"isTrusted":true}

I have used change and input events but it is giving me the same result. does $event object contains only "isTrusted" and doesn't have any other details or i did something wrong ?

k.elgohary
  • 363
  • 5
  • 19

1 Answers1

0

You need to use $event.target.value

Like this:

 <div *ngFor="let items of item>
      <input type="text" id="{{item.id}}" (change)="dummyFunc($event.target.value)">
</div>
schankam
  • 9,547
  • 2
  • 14
  • 25