Show option bootstrap [duplicated]

0

With this code I get the first ngfor options and I do not know how to show the first options first by default. How could he do it? By default I get the ngFor options and I want the first option.

<div class="form-group">
   <label for="exampleFormControlSelect1">Grup</label>
      <select class="form-control" id="operato" formControlName="company">
           <option disabled selected value>Escoja</option>
           <option *ngFor="let operat of operato;">{{operato.companyName}}</option>
       </select>
</div>
    
asked by David 12.12.2018 в 15:35
source

1 answer

0

How you have it works for me ... Or you can try replacing the disabled with hidden . I leave the two functional options.

<div class="form-group">
   <label for="exampleFormControlSelect1">Grup</label>
      <select class="form-control" id="operato" formControlName="company">
           <option value="" disabled selected>Escoja</option>
           <option *ngFor="let operat of operato;">{{operato.companyName}}</option>
       </select>
</div>
<br>
<div class="form-group">
   <label for="exampleFormControlSelect1">Grup</label>
      <select class="form-control" id="operato" formControlName="company">
           <option value="" hidden selected>Escoja</option>
           <option *ngFor="let operat of operato;">{{operato.companyName}}</option>
       </select>
</div>

Now, when selecting an option different from Escoja , you must reload the page to show you that option again.

    
answered by 12.12.2018 в 19:57