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

Filter by array property #62

Open
matthews90 opened this issue May 9, 2018 · 7 comments
Open

Filter by array property #62

matthews90 opened this issue May 9, 2018 · 7 comments

Comments

@matthews90
Copy link

I am trying to filter object with array property like this:

{ listName: "list1", users : [{name: "John", surname: "Riddle"}, {name: "Mark", surname: "Spancer"}]

It is possible to filter object by user property? I was trying something like this but it doesnt work

filterList = { users: {name: '' }}

@nechamam
Copy link

@matthews90 any news? I have the same problem

@VadimDez
Copy link
Owner

Could you show me how your collection looks like?

@renaholic
Copy link

I too have the same problem, and I can sort of filter them by using
filterList = { users: [{ name: "" }] }

my problem is that it can only filter by the first array
allow me to use @matthews90 's collection as an example
lists: any[] = [{ listName: "list1", users: [ { name: "John", surname: "Riddle" }, { name: "Mark", surname: "Spancer" } ] }, { listName: "list2", users: [ { name: "Mark", surname: "Spancer" }, { name: "John", surname: "Riddle" } ] }]
and in constructor:
constructor(private filterPipe: FilterPipe) { console.log(filterPipe.transform(this.lists, { users: [{ name: "John" }] }));

Only list1 appeared if filter by name: "John" and only list2 appeared if filter by name: "Mark"

@VadimDez
Copy link
Owner

Looks like this case is not covered.
Someone needs to take a look at this.
Created a demo: https://stackblitz.com/edit/ngx-filter-pipe-upza1y?file=app%2Fapp.component.ts

@renaholic
Copy link

@VadimDez but it only returns one list,
both lists (list1 and list2) have the same array of users object (but reversed in order)

and I think it should return both items?
or is there any method to return both of them?

@VadimDez
Copy link
Owner

I mean, you're right. It just seems that the case of filtering by array is not working.

@mvanveen82
Copy link

Got the same problem.
Trying to filter on object.arrary.object.value.
The filter only selects when the first object of the array passes. The rest does not seem to be looked at.

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

5 participants