0
votes

I am trying to build a filter for a table in angular:

<div>
    <input (keyup)="applyFilter($event.target.value)" matInput placeholder="Filter">
</div>

In that part of the code I am getting this error:

Property 'value' does not exist on type 'EventTarget'

2
Please check my answer and let me know does it resolve your problem or not. Best wishes. :-)SJNF

2 Answers

0
votes

I think, you did not declare applyFilter() function in the TS file. I have used the exactly the same HTML and I have used applyFilter() function like below=>

 applyFilter(data){
   console.log(data);
 }

and in console, it is showing the result. On the other hand hand, if you still facing the problem with (keyup) you can use (input) too. After trying all of them, if you still face problem then check the app.module.ts file and find FormsModule is imported or not.
Note: 1.

  1. Code for (keyup) Stackblitz Demo.

  2. Code for (input) Stackblitz Demo.

-1
votes
<input (keyup)="filter($any($event.target).value)">

This worked for me.