Trying to create an input with a clear button following the example from Angular Material, link to the example, what I want is to get the input value on a keypress enter event.
HTML:
<mat-form-field>
<input matInput (keydown.enter)="applyFilter($event)" placeholder="Search"
name="search" [(ngModel)]="searchValue">
<button mat-icon-button matSuffix aria-label="Clear" (click)="clearSearch()">
<mat-icon>close</mat-icon>
</button>
</mat-form-field>
TS:
applyFilter(event: any) {
console.log(JSON.stringify(event));
}
Results of the console when printing the event content:
{"isTrusted":true}
applyFilter($event.target.value)
? – ExoapplyFilter(searchValue)
– Exo$event.target.value
, it isevent.target.value
– Illegalize$event
in Angular. Same goes for(click), (input), (change) ...
– Exoevent.target.value
– Illegalize$event.target.value
in html orevent.target.value
in ts – Pergola