0

这是我的控制器:

   varDemoApp.controller('SimpleController',function($scope){
        $scope.customers = [{name:'Ahsan',city:'Khulna'},
            {name:'Rokib',city:'Bogra'},
            {name:'Asad',city:'Satkhira'}];

    });

我的html代码是:

<div data-ng-controller="SimpleController">
    Name:
    <br/>
    <input type="text" data-ng-model="name"/>
    <ul>
        <li data-ng-repeat="cust in customers|filter:name|orderBy:'name'">
            {{cust.city}}-{{cust.name}}
        </li>
    </ul>
</div>

我只想按“customers.name”过滤,但现在它按整体客户数组过滤。

4

1 回答 1

1

是的,您可以将对象传递给过滤器表达式:

filter:{name:name}
于 2014-05-19T09:12:56.457 回答