我有一个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;
}
有没有办法按字母顺序排列下拉列表中的项目?
答案 0 :(得分:2)
md-items="item in searchQuery(searchText1) | orderBy : display"
答案 1 :(得分:1)
md-items="item in querySearch(searchText) | orderBy : 'fieldName'"
为我工作!!