我正在使用angularJs在asp.net MVC4中工作.我想在下拉列表中添加“ng-model”.我的DropDownList是这样的:
@Html.DropDownList("UnitConversionId",(IEnumerable<SelectListItem>)ViewBag.UnitConversionId,"No Unit Seleced",new { ng-model="newItem.UnitConversionId" })
我也尝试过这个.但我收到一个错误:
@Html.DropDownList("UnitConversionId",new { @ng-model="newItem.UnitConversionId" })
有没有办法在DropDownList中添加“ng-model”?
解决方法
您可以通过在定义中将短划线更改为下划线来获取包含短划线(以及所有类型的HTML5数据属性)的任何类型的属性:
@Html.DropDownList("UnitConversionId",new { ng_model="newItem.UnitConversionId" })