这个问题在这里已有答案:
我正在使用角度7和MVC
我需要在html帮助器控件中使用[(ngModel)],我尝试了以下方法
@Html.DropDownList("StateCode", StateList, new { @class = "form-control", @id = "StateCode", @name = "StateCode", ng_model =StateCode" })
但它不会绑定下拉值。有解决方案吗
尝试绑定为[(ngModel)]
:
@Html.DropDownList("StateCode", StateList, new Dictionary<string, object>()
{
{ "class", "form-control" },
{ "id", StateCode },
{ "name", "4" },
{ "[(ngModel)]", "StateCode" }
})