My drop down arrow has elements that are not properly sorted. I have been attempting to use the orderBy
angular filter but have encountered some challenges. Upon further investigation, it seems the issue arises because the content I need displayed is nested within objects.
This snippet represents my front end:
%input-md{ type: 'select', "ng-model" => "vm.form.group", required: true, options: 'vm.groups', placeholder: 'Select your group' }
Within my controller, there is a function that deals with the groups:
init = ->
success = (groups) ->
vm.groups = groups
return
I inserted a debugger in the function after defining groups
and checked the JS console for groups which appeared as number of objects formatted like this:
text : "American group"
value : Object
__proto__ : Object
The objective is to sort these by their text field
, such as American group
.
I attempted:
%input-md{ type: 'select', "ng-model" => "vm.form.group", required: true, options: "object in vm.groups | orderBy: 'text'", placeholder: 'Select your group' }
However, an error regarding unrecognized text
occured. It stated
Failed to execute 'setAttribute' on 'Element': 'text'' is not a valid attribute name.
I am uncertain of what I may be overlooking and would appreciate any assistance in resolving this issue.
***** Edit ****
Further research revealed that orderBy() does not support objects, only arrays. This clarifies why my initial approach was unsuccessful. (still exploring solutions for this)