如何设置组标签排序 angularjs ui-select group-by

how to set group label ordering angularjs ui-select group-by

我正在使用 ui-select-choices group-by 对 UI select 中的列表进行分组,分组工作正常,但我面临的问题是组标签未按字母顺序排列,如下所示是一段代码

HTML:

<div class="col-md-5">
            <ui-select name="template" ng-model="template.data" theme="bootstrap"
              ng-disabled="ctrl.disabled" sortable="true">
              <ui-select-match placeholder="-- Select --">{{$select.selected.name}}</ui-select-match>
              <ui-select-choices group-by="'itemType'"
                repeat="rf in templates | propsFilter: {name: $select.search} | orderBy : 'name' : false">
                <div ng-bind-html="rf.name | highlight: $select.search"></div>
              </ui-select-choices>
            </ui-select>
          </div>

输出:

此输出的问题是组未按字母顺序排列,即。对于如何实现这一点,“客户”应该排在“用户”之前。

注意:我已经按项目类型对数组进行了排序,但输出没有变化。

提前致谢。

尝试 group-filter 选项:

<ui-select-choices group-by="'itemType'"
                   group-filter="orderFilterFn"
                   repeat="rf in templates | propsFilter: {name: $select.search} | orderBy : 'name' : false">
    <div ng-bind-html="rf.name | highlight: $select.search"></div>
</ui-select-choices>

并使用 $filter:

在函数 orderFilterFn 中执行排序
$scope.orderFilterFn= function(groups) {
    return $filter('orderBy')(groups, 'name');
};