Reputation:
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.
Upvotes: 0
Views: 194
Reputation: 39047
You can use Angular's built-in orderBy
filter:
<tr ng-repeat="user in objHodUserData | orderBy:'user_name' ">
Upvotes: 3