1

I want select a option in my select - option in my html with Angular2 , but I need do this for code.

<select name="lastDataVi" [(ngModel)]="lastDataVi">
   <option [ngValue]="undefined" selected="true" disabled="disabled">Select option</option>
   <option [ngValue]="vicombo.id" *ngFor="let vicombo of paramsServer.vicombo"> {{ vicombo.id}} </option>
   </select>

although I have my
<option [ngValue]="undefined" selected="true" disabled="disabled">Select option</option>

I need when I do click the button , Put the select- option in the frist option ->

<option [ngValue]="undefined" selected="true" disabled="disabled">Select option</option>

EduBw
  • 866
  • 5
  • 20
  • 40

2 Answers2

1

You need to use [value] instead of [ngValue]

 <option  *ngFor="let vicombo of paramsServer.vicombo" [value]="vicombo.id"> {{ vicombo.id}} </option>
Suhag Lapani
  • 655
  • 10
  • 18
0

You could use

<option selected="true" disabled="true"></option>

You need not use ngValue.

pooja patil
  • 91
  • 1
  • 9
  • nop. without ngValue. In html never shows 1º option – EduBw Sep 24 '18 at 08:47
  • Also you could refer this https://stackoverflow.com/questions/5805059/how-do-i-make-a-placeholder-for-a-select-box – pooja patil Sep 24 '18 at 08:51
  • Created a plunker. See if it helps http://next.plnkr.co/edit/NzQ1skgIrliMIGgEPkp8?p=preview&utm_source=legacy&utm_medium=banner&utm_campaign=next&preview – pooja patil Sep 24 '18 at 10:05