angular - 使用 ngModel、ngFor 和 Angular dropDownList
问题描述
使用此 html 代码:
<div class="form-group">
<select name="dropDownList1" class="form-control form-control-sm">
<option *ngFor="let s of list_of_Values;" id="field_status" name="field_status" >{{s}}</option>
</select>
<select name="dropDownList2" class="form-control form-control-sm">
<option *ngFor="let s of list_of_Values;" id="field_status" name="field_status" >{{s}}</option>
</select>
</div>
这个打字稿代码:
list_of_Values:string[]=['value1','value2','value3','value4']
list_of_Chosen_Values:string[]=['chosenValueOfList1','chosenValueOfList2']
我想做的是使用
模型
在选项标签内:
<option *ngFor="let s of list_of_Values;" id="field_status" name="field_status" >{{s}}</option>
绑定 的值:
list_of_Chosen_Values:string[]=['chosenValueOfList1','chosenValueOfList2']
用户在两个列表中选择的值。
这甚至可行吗?
解决方案
推荐阅读
- c# - Json.net 转换器没有被调用
- android - 将旧的 Android 项目迁移到 Gradle 后,R 未知
- javascript - 如何使用 should.js 断言函数已“等待”异步函数
- mysql - mysql表中的多个连接与联合
- android - 从 BroadcastReceiver 向 Service 发送消息
- authentication - FaceID 身份验证永远不会因真实 iPhoneX 上的“authenticationFailed”策略错误而失败
- ios - SKSpriteNode init(texture: atlas!.textureNamed("something") 在 iPhone X 上加载不正确
- c# - 从数据集中获取行列表
- c# - 如何在 UltraTreeNode 集合中添加自定义属性(Infragistics UltraTree 控件)
- android - 重新加载应用程序时删除数据的共享首选项