angular - 如何自动显示数据列表的下拉列表?
问题描述
在这种情况下,当数据被获取并填充到datalist
?
<input class="header-filter-search" (change)='onTaxpayerChosen($event)' [(ngModel)]="searchValue" placeholder=" Search accounts" type="text" (blur)="searchForUser()" [formControl]="query" list="accounts" id="account"/>
<datalist id="accounts">
<option *ngFor="let account of taxpayerList">{{account.name}}</option>
</datalist>
填写选项后,我目前必须选择一个小箭头来显示下拉列表,但我无法在网上找到任何可用于自动显示这种格式的下拉列表的内容?
解决方案
使用*ngIf="taxpayerList"
声明。这意味着您dataList
将不会被渲染,直到taxpayerList
不会被填充:
<datalist id="productList">
<select *ngIf="taxpayerList">
<option *ngFor="let account of taxpayerList">
{{account.name}}
</option>
</select>
</datalist>
更新:
<p>Debug info: taxpayerList {{ taxpayerList | json }}</p>
<select>
<option *ngFor="let account of taxpayerList" [value]="account.name"></option>
</select>
推荐阅读
- php - WooCommerce - 如何通过自定义用户元编程重置密码
- omnet++ - 在 ns2 中获取机会路由的代码
- c# - 将 T4 输出从导入的程序集保存到文件
- php - wp admin在复选框更改后填充选择下拉列表
- c - 关于 PPM 格式卷积的特殊问题
- javascript - 如何解决 React Native 中的“找不到变量:App”?
- amazon-s3 - 存储桶策略允许上传某些文件类型
- python - 请求和生成器。并行计算和请求
- java - 将来自多个活动的数据保存到一个 id firebase 数据库,而不是创建两个不同的 id
- postgresql - 在 Power BI 中选择 postgresql 数据表时出现 OBDC 错误 0A000