加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 如何在DropDownList中添加“ng-model”?

发布时间:2020-12-15 18:04:10 所属栏目:百科 来源:网络整理
导读:我正在使用angularJs在asp.net MVC4中工作.我想在下拉列表中添加“ng-model”.我的DropDownList是这样的: @Html.DropDownList("UnitConversionId",(IEnumerableSelectListItem)ViewBag.UnitConversionId,"No Unit Seleced",new { ng-model="newItem.UnitCon
我正在使用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" })

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读