ranjit.menon9 (1) [Avatar] Offline
#1
Hi

I have a requirement to sort a table in my MVC razor UI. The table was generated using scaffolding option in MVC and bound to a model. The code looks something like below

@model IEnumerable<Avanade.Bureau.DataAccessLayer.DatabaseModel.SubscriptionType>

@{
ViewBag.Title = "Subscriptions";
Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Subscriptions</h2>

<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.Code)
</th>
<th>
@Html.DisplayNameFor(model => model.Description)
</th>
<th></th>
</tr>

@foreach (var item in Model)
{
<tr ng-repeat="table in Model | orderBy:predicate:reverse">
<td>
@Html.DisplayFor(modelItem => item.Code)
</td>
<td>
@Html.DisplayFor(modelItem => item.Description)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
@Html.ActionLink("Subscribe", "Index", "Subscription", new { id = item.Id }, null)
</td>
</tr>
}

</table>


I want to use Angularjs to do sorting.All the examples that I have seen so far taken show examples of data that is hardcoded in the view. As you can see my view is bound to the model which gets the data from the database via the controller. Could someone help.
Maslovian (31) [Avatar] Offline
#2
Re: Sorting using Angularjs in MVC
can you provide sample html that the mvc outputs?