Angular SearchTerm get value

app.component.ts

import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
public searchStr: string = ""
private searched: Array<string> = [];
public modelChange(str: string): void {
this.searchStr = str;
console.log("Searching for " + this.searchStr);
// Add code for searching here
this.searched.push(str);
}
}

app.component.html

Search for <input [ngModel]="searchStr" (ngModelChange)="modelChange($event)" />
<h3>Search history</h3>
<div *ngFor="let item of searched">Searching: {{item}}</div>

check here for code run