dongyuan9109 2015-11-26 04:22
浏览 65
已采纳

如何使用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条回答 默认 最新

  • douxuanma4357 2015-11-26 04:27
    关注

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

    <tr ng-repeat="user in objHodUserData | orderBy:'user_name' ">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?