Rodney Wormsbecher
Rodney Wormsbecher

Reputation: 927

Angular 1.5 sort in <select ng-options>

I have seen similar posts on stack overflow but I have tried them all and can't seem to get it working.

I want to sort my angular dropdown list alphabetically but for some reason it doesn't understand the "|orderby:" filter.

My code is as follows:

 <select class="form-control" ng-
model="widget.documentSelectedGroupName.groupName" 
id="widgetselectedGroupName" ng-options="group as group.groupName for group 
in widget.GroupNameSearch 
| orderBy:group.groupName track by group.mailNickname">

Thanks for the help in advance.

Upvotes: 0

Views: 41

Answers (1)

Sai
Sai

Reputation: 2658

You don't need to add extra group there. Just simplt try:

<select class="form-control" ng-model="widget.documentSelectedGroupName.groupName" id="widgetselectedGroupName" ng-options="group as group.groupName for group in widget.GroupNameSearch | orderBy:groupName ">

You can't combine track by and as in ng-options.

Upvotes: 1

Related Questions