在 angular js 中过滤 (key,value) 的数组

Filtering array of (key,value) in angular js

我正在 angular 1.x 中编写一段代码,我想在其中过滤键值数组。

HTML:

<input type="text" ng-model="cust"> 

<div ng-repeat="customer in customers| filter :cust['name']">
    {{customer["name"]}}
</div>

JS:

$scope.customers = [
    {"name":"Sathish"},
    {"name":"Ankur"},
    {"name":"Bob"},
    {"name":"Mike"},
    {"name":"chris"},
    {"name":"chrom"}
];

Basically I want to filter the array based on name of customer. if I give "ch" in the input text box it should give filter and give chris and chrom.

您想根据客户名称进行过滤,但客户只是一个字符串,因此不确定您当前正在做什么。正确的方法是:

<div ng-repeat="customer in customers| filter :{name : cust}">