Method 1.
Using `ngModel`.@Component({ selector: 'my-app',template: ` <div> <input type="text" placeholder="Search..." [(ngModel)]="searchValue"> <button (click)="clearSearch()">Clear</button> </div> `,}) export class App { searchValue:string = ''; clearSearch() { this.searchValue = null; } }
Method 2.
Using null value instead of empty quotation marks.
|