我有一系列用户:
$scope.users = [
{name: 'Anh', age: 10},
{name: 'Ánh', age: 10},
{name: 'Ba' , age: 10}
]
当我使用orderBy:'name'
时,结果为:
但是当我使用多个字段orderBy:['name','age']
时,结果会有所不同:
等待你的帮助!
答案 0 :(得分:0)
试试这个..
var app = angular.module('filterSample', []);
app.controller('filterCtrl', function ($scope) {
$scope.data = {
messages: ['first', 'second', '3rd', 'fourth', 'fifth']
}
$scope.startsWith = function (actual, expected) {
var lowerStr = (actual + "").toLowerCase();
return lowerStr.indexOf(expected.toLowerCase()) === 0;
}
});
和html为
<ul border="1px" ng-repeat="msg in data.messages | filter:search:startsWith">
<li>{{msg}}</li>
</ul>
或查看此plunkr - http://plnkr.co/edit/gcVYfZXTqsDU1Z7REU2I?p=preview