Clear Select value in Angular 2

Discussão em 'Angular' iniciado por Femil Shajin, Outubro 30, 2024.

  1. Femil Shajin

    Femil Shajin Guest

    I have a select input where I have to clear the selected value. Here even If if set valueS = null Select is still showing last selected value. When I on the button to clear the selected value from Select. How to achieve it?

    <select (ngModelChange)="onChange($event)" [(ngModel)]="valueS">
    <option value="null" >Add filter</option>
    <option value="Hi">Hi</option>
    <option value="Hey">Hey</option>
    <option value="Hello">Hello</option>
    </select>
    <button (click)="clear()">Clear</button>


    in Component:

    clear() {
    this.valueS = null
    }

    Continue reading...

Compartilhe esta Página