如何使用Angular.js和PHP按字母顺序显示列表

I need one help.I am using Angular.js in my app.I have some list and the contents are coming from the DB.Here I need the list order should be alphabetical.I am explaining my code below.

<thead>
<tr>
<th>Sl. No</th>
<th> Name</th>
<th>User Email</th>
<th>Mobile No</th>
<th>Login Name</th>
<th>Status</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>

<tbody id="detailsstockid">
<tr ng-repeat="user in objHodUserData">
<td>{{$index+1}}</td>
<td>{{user.user_name}}</td>
<td>{{user.email}}</td>
<td>{{user.mob_no}}</td>
<td>{{user.login_name}}</td>
<td ng-if="user.user_status==1">Enable</td>
<td ng-if="user.user_status==0">Disable</td>
<td>
<a ui-sref='hod.user'>
<input type='button' class='btn btn-xs btn-green' value='Edit' ng-click="editUserData(user.user_id)" >  
</a>
</td>
<td>
<a ui-sref='hod.user'>
<input type='button' class='btn btn-xs btn-red' value='Delete' ng-click="deleteUserData(user.user_id);" >  
</a>
</td>
</tr>   
</tbody>

In this case i am adding data according to database descending order.Here I need to add data in alphabetically(e.g.A,B,C....).Please help me to resolve this problem.

1个回答

You can use Angular's built-in orderBy filter:

<tr ng-repeat="user in objHodUserData | orderBy:'user_name' ">
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问