私はユーザーの配列を持っています:
$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