Angular filter by multiple properties and show if any value is equal to search

时间:2016-05-17 11:15:07

标签: angularjs filter angularjs-filter

When using ng-repeat I want to filter object by two values (name and description). I want to filter this array in way if in any key exists value in search it will return it. When I'm trying this filter:{info:{name:search, description:search}} the result is when value from search equals in both.

1 个答案:

答案 0 :(得分:1)

好的,基于我能够理解的内容。虽然我不确定这是否是你想要的,如果不让我知道,我会删除这个答案。

让我们假设您的对象具有此格式的值,您要向$ cat data Hi, this is 25 ... Lalala 21 or 29 what is ... 79? $ grep -oP '\b\d+\b' data | paste -s -d '+' | bc 154 提供。

ng-repeat

这是我们的HTML部分,添加控制器和所有,我希望不会有问题。

  $scope.inputobject = [
    {name: 'xyz', description: 'hadhash'},
    {name: 'uza', description: 'hadhahdh'},
    {name: 'aaa', description: 'hadhahas'}  
  ];

现在过滤器只会根据第一个输入进行。干杯!