1<input type="text" [(ngModel)]="name" required />
2<button (click)="handleClear()">Clear input field</button>
1import { Component } from '@angular/core';
2
3@Component({
4 selector: 'my-app',
5 templateUrl: './app.component.html',
6 styleUrls: [ './app.component.css' ]
7})
8export class AppComponent {
9 name = 'Angular';
10 handleClear(){
11 this.name = ' '; }
12}