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

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

概述我正在使用angularJs在asp.net MVC4中工作.我想在下拉列表中添加“ng-model”.我的DropDownList是这样的: @Html.DropDownList("UnitConversionId", (IEnumerable<SelectListItem>)ViewBag.UnitConversionId, "No Unit Seleced", new { ng-model= 我正在使用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" })
总结

以上是内存溢出为你收集整理的c# – 如何在DropDownList中添加“ng-model”?全部内容,希望文章能够帮你解决c# – 如何在DropDownList中添加“ng-model”?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/langs/1239032.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-06
下一篇2022-06-06

发表评论

登录后才能评论

评论列表(0条)

    保存