Problem

How to have a default option using angular 2 ou plus ?

Solution

if you have a select and you want to set a default value using angular , Add a binding to the selected property, like this :

<option *ngFor="#workout of workouts" 
    [selected]="workout.name == 'back'">{{workout.name}}</option>

Read also : How to click on html button from the type script file in Angular 2 ?

Laisser un commentaire