使用Angular在.net中填充数据库中的下拉列表

时间:2015-05-12 02:15:10

标签: asp.net angularjs

我试图同时学习ASP.net和Angular。 我想要做的是使用Angular在下拉列表中显示状态列表(从数据库中检索)。我可以让状态显示在表格中。 这就是我所拥有的:

我的控制器功能:

public ActionResult StateListDistinct()
{
    var distinctStates = (from w in db.Addresses
                              select new { State =    
w.address_state}).Distinct();

        List<string> states = db.Addresses.Select(state => state.address_state).Distinct().ToList();

        return View(states);

    }

我目前的观点:

@model List<String>

<table class="table">

@foreach (var item in Model) {
    <tr>

        <td>
            @Html.DisplayFor(model => item)
        </td>

    </tr>
}

</table>

使用Angular填充下拉列表需要做什么?

1 个答案:

答案 0 :(得分:2)

您可以访问以下链接,了解使用AngularJs

学习下拉列表绑定

http://techbrij.com/angularjs-cascade-dropdownlist-asp-net-mvc

您也可以访问此链接                                                                                                                                                                                                                                                http://www.aspdotnet-suresh.com/2015/02/angularjs-bind-set-dropdownlist-value-text-using-ng-options-ng-repeat.html

相关问题