angular-filter icon indicating copy to clipboard operation
angular-filter copied to clipboard

filterBy with boolean field is not working for me

Open germanger opened this issue 8 years ago • 1 comments

$scope.users = [
  { id: 1, first_name: 'Rob', last_name: 'John',  mobile: 4444, isFoo: false },
  { id: 2, first_name: 'John', last_name: 'Wayne',  mobile: 3333, isFoo: false },
  { id: 3, first_name: 'Rob', last_name: 'Johansson',  mobile: 2222, isFoo: false },
  { id: 4, first_name: 'Mike', last_name: 'Terry',  mobile: 1111, isFoo: true }
];

Return users whose isFoo is true:

<!--search only by id -->
<th ng-repeat="user in users | filterBy: ['isFoo']: true">
  {{ user.id }} : {{ user.first_name }} {{ user.last_name }}
</th>

Result:

All users... why?

germanger avatar May 02 '17 21:05 germanger

You can use Pick or Omit for filter some variable . in your case should be

user in users | pick:'isFoo'

Nineapsofttech avatar Mar 20 '18 16:03 Nineapsofttech