0

我有一个 md-autocomplete 字段:

<md-autocomplete md-selected-item="videoInfo.lineUp[1]" md-items="item in searchQuery(searchText1)" md-search-text="searchText1" md-item-text="item.display" md-floating-label="Loosehead">
    <span md-highlight-text="searchText1">{{item.display}}</span>
</md-autocomplete>

md-items我填充

$scope.searchQuery = function (searchText) {
    var users = [];
    angular.forEach($scope.users,
        function (value, key) {
            // value = user object
            // key = userId
            var dN = value["display_name"];
            if (dN) {
                var obj = {};
                obj[key] = value;
                obj["display"] = dN;
                if (dN.toLowerCase().indexOf(searchText.toLowerCase()) !== -1) {
                    users.push(obj);
                }
            }
        });
    return users;
}

有没有办法按字母顺序对下拉列表中的项目进行排序?

4

2 回答 2

3
md-items="item in querySearch(searchText) | orderBy : 'fieldName'"

为我工作!

于 2018-06-29T11:01:34.367 回答
2
md-items="item in searchQuery(searchText1) | orderBy : display"
于 2016-09-11T07:23:09.390 回答