【发布时间】:2018-10-14 00:23:13
【问题描述】:
我在以下情况下遇到问题,谁能指导我。
场景: 从已经用户输入的数据库中获取逗号分隔的 ID,然后拆分值,然后在编辑模式下将值绑定到多选列表框控件。
我尝试了以下代码来实现它,但它不适合我。
@Html.ListBoxFor(c => c.ClientDemographicHospitalId, new MultiSelectList(Model.Hospitals, "Value", "Text"), new { ng_model = "hospitalDropdownList", @class = "HospitalListbox", style = "width:65%" })
var lstSelectedIDs = employee.ClientDemographicHospitalId;
var arySelectedID = lstSelectedIDs.split(",");
for (var i = 0; i <= arySelectedID.length; i++) {
$scope.hospitalDropdownList.append($('<option></option>').val(arySelectedID[i].Value).html(arySelectedID[i].Text));
}
附上截图。
代码:
控制:
【问题讨论】:
-
为什么要混合使用 jquery 和 AngularJS?这是一个不好的做法
标签: javascript jquery angularjs asp.net-mvc jquery-ui