Default option in select does not appear

Asked

Viewed 282 times

0

I have a select I want to show a label as default option, but it is appearing blank.

My select:

<div class="select">
    
    <select (change)="calculaMes(mesEscolhido)" [(ngModel)]="mesEscolhido" name="selectMesEscolhido"
    class="select-text">
       <option class="dropdown-item" disabled selected value>Teste</option>
       <option [hidden]="datasComMovimentacoes[x].data == mesEscolhido" *ngFor="let mes of datasComMovimentacoes;let x = index"
       class="dropdown-item">{{mes.data}}</option>
    </select>

   <span class="select-highlight"></span>
   <span class="select-bar"></span>

</div>

This is the result I have in my template:

inserir a descrição da imagem aqui

  • And tag <label>?

  • To add a default value just add it to the model, this.mesEscolhido = SUA OPCAO in the ts file, the angular itself will find the value in the options list and select

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.