Angular SearchTerm get value

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

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store