ngx-pipes
ngx-pipes copied to clipboard
Can not filter by deep nested property of array
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
Anyone already have a proper solution or workaround for this?
I have the same issue with nested objects (with dynamic object keys)

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.