我正在 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.
最佳答案
您想根据 cust 名称进行过滤,但 cust 只是一个字符串,因此不确定您当前正在做什么。正确的方法是:
<div ng-repeat="customer in customers| filter :{name : cust}">
关于javascript - 在 Angular js中过滤(键,值)数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44163992/