OnLearn OnLearn - 2 months ago 14
HTML Question

HTML selection automatically selects first entry

I have the following code:

<select #typ class="input" (change)="changeIndex(typ.value)">
<option *ngFor="let creation of creationComponent>{{}}</option>

If I start the application the selection has automatically selected the first option. But I don't want that. Why is this and how can I fix it?

Answer Source

The trick is setting an empty option with display:none.

  <option style="display:none"></option>