I am working in asp.net MVC4 with angularJs. I am trying to add an "ng-model" to dropdownlist. My DropDownListis like this:
@Html.DropDownList("UnitConversionId", (IEnumerable<SelectListItem>)ViewBag.UnitConversionId, "No Unit Seleced", new { ng-model="newItem.UnitConversionId" })
I also tried this. But I am getting an error:
@Html.DropDownList("UnitConversionId", (IEnumerable<SelectListItem>)ViewBag.UnitConversionId, "No Unit Seleced", new { @ng-model="newItem.UnitConversionId" })
Is there any way to add an "ng-model" to DropDownList?
You can get any kind of attribute that contains a dash (so also all kinds of HTML5 data attributes) to render by changing the dash to underscore in the definition:
@Html.DropDownList("UnitConversionId", (IEnumerable<SelectListItem>)ViewBag.UnitConversionId, "No Unit Seleced", new { ng_model="newItem.UnitConversionId" })
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With