如何在html帮助器控件中使用[(ngModel)],例如@ Html.DropDownList [duplicate]

问题描述 投票:0回答:1

我正在使用角度7和MVC

我需要在html帮助器控件中使用[(ngModel)],我尝试了以下方法

 @Html.DropDownList("StateCode", StateList, new { @class = "form-control", @id = "StateCode", @name = "StateCode", ng_model =StateCode" })

但它不会绑定下拉值。有解决方案吗

razor data-binding angular7 html-helper
1个回答
0
投票

尝试绑定为[(ngModel)]

@Html.DropDownList("StateCode", StateList, new Dictionary<string, object>()
    {
        { "class", "form-control" },
        { "id", StateCode },
        { "name", "4" },
        { "[(ngModel)]", "StateCode" }
    })
© www.soinside.com 2019 - 2024. All rights reserved.