我一直试图在点击时对表格数据进行排序(ng-click,如果我使用angularJS) 我从database.I获取数据只需要排序功能,如果它通过angularJs发生我会很高兴AngularJs对已经插入的数据进行排序
这是我做的到现在为止,我没有做太多,因为我是新来的AngularJS
@model WebApplication3.Models.StudentModel
@{
ViewBag.Title = "Index";
}
<h2>Students</h2>
<div><button class="create btn btn-success"><span class="glyphicon glyphicon-plus"></span> Create New</button></div>
<br/>
<table class="table" ng-app="StudentApp">
<tbody ng-controller="StudentCtrl">
<tr>
<th>Key</th>
<th ng-click="">First Name</th>
<th ng-click="">Last Name</th>
<th>Profile picture</th>
<th>Options</th>
</tr>
@foreach (var student in Model._StudentList)
{
<tr>
<td>@student.StudentID</td>
<td>@student.FirstName</td>
<td>@student.LastName</td>
<td>
<a class="example-image-link" href="~/Images/@student.PhotoURL" data-lightbox="example-set" data-title="@student.FirstName @student.LastName profile Picture"><img class="example-image" width="60" height="40" src="~/Images/@student.PhotoURL" alt="" /></a>
</td>
<td>
<a href="#" class="edit" data-studentid="@student.StudentID"><span class="glyphicon glyphicon-pencil img-rotate" title="Edit"></span></a>
<a href="#" class="details" data-studentid="@student.StudentID"><span class="glyphicon glyphicon-exclamation-sign img-rotate" title="Infomation"></span></a>
<a href="#" class="delete" data-studentid="@student.StudentID"><span class="glyphicon glyphicon-remove img-rotate" title="Remove"></span></a>
</td>
</tr>
}
</tbody>
</table>
我需要排序名字,姓氏当他们点击相应的th标签
谢谢
哦,那很伤心,我可以绑定我的MVC模型数据AngularJs 我的意思就像我们绑定JSON数据 var people = []; 例如:$ scope.People = json.data – Arjun
哦,那很伤心,我可以绑定我的MVC模型数据到AngularJs 我的意思是像我们绑定JSON数据 var app = angular.module('studentApp',[]); app.controller( 'StudntCtrl',函数($范围,$ HTTP){ htp.get( 'Student.json')成功(功能(数据){$ = scope.People数据; }); }); 像明智的我可以将MVC模型数据绑定到$ scope.People? – Arjun
是的,你可以使用ng-init:[example](http://www.w3schools.com/angular/angular_directives.asp)在你的视图中设置变量。然后,你可以通常在你的控制器中使用它。 –