0

By using [(ngModel)]="topic.id" we can get it but then default value is not shown in dropdown. Do we have any other option to access selected value?

More of my code is given below:

<select class="form-control input-lg" name="topicId" ngModel>
    <option value="" disabled>Choose a state</option>
    <option *ngFor="let inquiryTopic of inquiryTopics"
 [ngValue]="inquiryTopic.id" >{{inquiryTopic.name}}</option>
</select>
peinearydevelopment
  • 11,042
  • 5
  • 48
  • 76
AshwiniVD
  • 1
  • 2
  • to give a default value, you can use this.topicId=inquiryTopics[0].id – Eliseo Feb 14 '18 at 14:11
  • yeah but i want default value as "Choose a state" a static string – AshwiniVD Feb 14 '18 at 14:15
  • Sorry, I read so quickly. Don't work this.topicId=""?. Any way check https://stackoverflow.com/questions/5805059/how-do-i-make-a-placeholder-for-a-select-box – Eliseo Feb 14 '18 at 14:28

0 Answers0