简体   繁体   English

如何使用Angular5 / 6显示下拉列表选择的项目?

[英]How to display Dropdown selected Item using Angular5/6?

I want to display selected item in Dropdown list based on id. 我想根据ID在下拉列表中显示选定的项目。

<div class="formrow" *ngFor='let a of applicantName'>
  <label>Status Selection :</label>
  <select id="AStatus" formControlName="AStatus" class="form-control">
    <option value="0">All</option>
    <option *ngFor="let apt of applicantStatus" [value]="apt.ApplicantStatusID" [selected]="apt.ApplicantStatusID === a.Status">
      {{ apt.ApplicantStatus }}
    </option>
  </select>
</div>

This code is not working and not showing selected option. 该代码不起作用,并且未显示所选选项。

value should be set for select not for option. value应设置为select not for option。

<div class="formrow" *ngFor='let a of applicantName'>
  <label>Status Selection :</label>
  <select id="AStatus" [value]="apt.ApplicantStatusID" formControlName="AStatus" class="form-control">
    <option value="0">All</option>
    <option *ngFor="let apt of applicantStatus" [value]="apt.ApplicantStatusID">
      {{ apt.ApplicantStatus }}
    </option>
  </select>
</div>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Angular中的Bootstrap下拉标题上显示所选项? - How to display the selected Item on Bootstrap Dropdown Title in Angular? 如何在dropDown上显示所选列表项的文本? - How to display text of selected List item on dropDown? 如何从Bootstrap下拉菜单中显示所选项目? - How to display selected item from Bootstrap dropdown? 如何使用 angular 离子中的 json 数据在其他下拉列表中根据选定的 state 在一个下拉列表中显示城市? - how to display cities in one dropdown based on selected state in other dropdown using json data in angular ionic? 如何在引导程序下拉列表的标题中显示所选项目? 以及如何在JavaScript警报框中显示所选项目? - How to display selected item in the title of the bootstrap dropdown list ? and how to display selected item on a javascript alert box? 如何在ul下拉菜单中显示所选菜单项 - How to display selected menu item in ul dropdown menu 如何在Bootstrap下拉标题中显示带有图标的所选项目? - How to display selected item with icons in Bootstrap dropdown title? 如何在引导程序中选择项目时更改下拉列表的主显示 - How to change the main display of dropdown when an item is selected in bootstrap 如何使用angular2和Typescript使选定的下拉值在更改时显示在标题上 - How to make the selected dropdown value to display on the header on change using angular2 and typescript Angular 2 - 如何显示多选下拉菜单的选定选项? - Angular 2 - How to display selected option for multi select dropdown?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM