0

私はユーザーの配列を持っています:

$scope.users = [
  {name: 'Anh', age: 10},
  {name: 'Ánh', age: 10},
  {name: 'Ba' , age: 10}
]

orderBy:'name'結果は次のとおりです。

  1. アン
  2. アン

しかし、複数のフィールドを使用するorderBy:['name','age']と結果が異なります:

  1. アン
  2. アン

あなたの助けを待っています!

4

1 に答える 1

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

于 2015-02-02T13:58:09.480 に答える