我有一个 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;
}
有没有办法按字母顺序对下拉列表中的项目进行排序?