1

i have created one drop down and i want to show the first value by default in drop down.

<select > 
          <option let i = index;" [selected]="i===0" >{{role.name}}</option>
          </select>  

but this code is not working. when I am removing, on this time I am able to see the first value by default in drop down.

rajeev tejapuriya
  • 133
  • 1
  • 2
  • 12

1 Answers1

0

Since you are using [(ngModel)], if you have no value there in roleVal, nothing will be chosen. You can solve this by giving it the initial value:

roleVal = this.addwrkfrcePopUpMdl.userRole[0].name

which means you can remove [selected] altogether.

AT82
  • 71,416
  • 24
  • 140
  • 167