以下是无效的代码:演示:http://jsfiddle.net/8dt94/63/
<div ng-controller="MyCtrl">
<input type="text" ng-model="searchText" />
<ul ng-repeat="strVal in arrVal|orderBy|filter:searchText" >
<li>{{strVal}}</li>
</ul>
</div>
var app=angular.module('myApp', []);
app.controller('MyCtrl', function ($scope,$filter) {
$scope.arrVal = ['one','two','three','four','five','six'];
});
答案 0 :(得分:242)
您可以通过方法进行排序,因此可以使用toString方法
<ul ng-repeat="strVal in arrVal | orderBy:'toString()' | filter:searchText">
答案 1 :(得分:11)
写一个custom filter:
app.filter('mySort', function() {
return function(input) {
return input.sort();
}
});
HTML:
<ul ng-repeat="strVal in arrVal|filter:searchText|mySort">