我有一组用户:
$scope.users = [
{name: 'Anh', age: 10},
{name: 'Ánh', age: 10},
{name: 'Ba' , age: 10}
]
当我使用orderBy:'name'
结果是:
- 安
- 安
- 巴
但是当我使用多个字段时orderBy:['name','age']
,结果是不同的:
- 安
- 巴
- 安
等待您的帮助!
我有一组用户:
$scope.users = [
{name: 'Anh', age: 10},
{name: 'Ánh', age: 10},
{name: 'Ba' , age: 10}
]
当我使用orderBy:'name'
结果是:
但是当我使用多个字段时orderBy:['name','age']
,结果是不同的:
等待您的帮助!
尝试这个..
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