Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not filter by deep nested property of array #181

Open
LukeMcDonnell opened this issue Sep 9, 2020 · 1 comment
Open

Can not filter by deep nested property of array #181

LukeMcDonnell opened this issue Sep 9, 2020 · 1 comment

Comments

@LukeMcDonnell
Copy link

LukeMcDonnell commented Sep 9, 2020

I'm submitting a ... (check one with "x")

[x ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
  • Ngx-pipes version: 2.7.5

Current behavior
filterBy doesn't work with nested properties within arrays. Likely affects other Array pipes that use the extractDeepPropertyByMapKey and extractDeepPropertyByParentMapKey methods.

Expected behavior
Filter should work

Minimal reproduction of the problem with instructions
Using a slightly modified example from the documentation:

this.users = [
   {id: 1, first_name: 'John', last_name: 'Doe', work: { company: 'Foo Tech' }},
   {id: 2, first_name: 'Jane', last_name: 'West', work: { company: 'AAA Solutions' }},
   {id: 3, first_name: 'Bruce', last_name: 'John', work: { company: 'Bar Tech' }},
   {id: 4, first_name: 'William', last_name: 'Cent', work: { company: 'Foo Tech' }, arr: [{name: {first_name: foo, last_name: bar}]}
];

we should be able to filter by nested properties within arrays, eg:

<p>{{ users | filterBy: ['arr.name.first_name']: 'foo' }}</p>
<!--Expected Output: "[{id: 4, first_name: 'William', last_name: 'Cent', work: { company: 'Foo Tech' }, arr: [{name: {first_name: foo, last_name: bar}]}]" -->
<!--Actual Output: "[]" -->
  • Angular version: 10.0.14

  • Node (for AoT issues): node --version = 12.18.2

@basvandorst
Copy link

Anyone already have a proper solution or workaround for this?

I have the same issue with nested objects (with dynamic object keys)

image

Map the items to an array can fix this for me, but of course a solutions with a wildcard filterBy: 'categories.*.title' would be great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants