So when I used the $event with the onkeyup event and I want the value of the input filed to pass it to the filter Function it doesn't work
<div >
<div >
<div >
<p >
<input #filterInput type="text" (keyup)="filterNotes($event.target.value)" placeholder="Filter">
<span >
<i ></i>
</span>
</p>
</div>
</div>
</div>
the class componet :
filterNotes(query: string) {
// some logic
}
CodePudding user response:
simply add to the
"angularCompilerOptions":{
"strictDomEventtypes":false
}
in your tsconfig.json file
CodePudding user response:
In this context I think $event.target
is not typed so typescript does not know what type of target it is, try the code below:
in the .html file pass only the event:
...
<input (keyup)="filterNotes($event)">
...
in the .ts file modify your method to receive an event:
filterNotes(event: Event): string {
const { value } = event.target as HTMLInputElement // forcing the type
// the rest of yout logic goes here
}