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

value.toLowerCase is not a function #28

Closed
dearibujar opened this issue Mar 7, 2017 · 14 comments
Closed

value.toLowerCase is not a function #28

dearibujar opened this issue Mar 7, 2017 · 14 comments

Comments

@dearibujar
Copy link

I try to use your pipe on a table , and i get this error value.toLowerCase is not a function

@VadimDez
Copy link
Owner

VadimDez commented Mar 7, 2017

Could you provide more details? For example the data you are trying to filter.

@dearibujar
Copy link
Author

I am using the filter on a array of objects, where each user is an object, there are nested objects in users.

@VadimDez
Copy link
Owner

VadimDez commented Mar 7, 2017

okay, and what is your filter ?

@dearibujar
Copy link
Author

dearibujar commented Mar 7, 2017

Oops :S it is a string . How should i use it then on an object? I am new to angular2 sorry.

@VadimDez
Copy link
Owner

VadimDez commented Mar 7, 2017

You need to make the filter similar to the object you want to filter. For example you want to filter users by their name:

users: any[] = [{ name: 'John' }, { name: 'Jane' }, { name: 'Mario' }];

then your filter would be:

userFilter: any = { name: '' };

@VadimDez VadimDez closed this as completed Mar 7, 2017
@dearibujar
Copy link
Author

Even with object i get the same error. Could you describe it a little better how it should be used. With an example where there are used more fields in *ngFor not just name, and using a table where users are shown in rows?

@VadimDez
Copy link
Owner

VadimDez commented Mar 8, 2017

That would be the same for more fields in the object

users: any[] = [{ name: 'John', age: 25 }, { name: 'Jane', age: 26 }, { name: 'Mario', age: 25 }];
userFilter: any = { name: '', age: null };

@dearibujar
Copy link
Author

Does that mean that i have to include in the filter object all the user object properies and set them to null? However thank you for helping

@VadimDez
Copy link
Owner

VadimDez commented Mar 8, 2017

No, what i wanted to say is - you just need to add fields that you want your array of objects to be filtered by. In that case i did an example when i would filter by name AND age. If you have more fields or nested fields you would add once that you want to filter by, just match the structure of your objects.

@dearibujar
Copy link
Author

No luck yet, here is my filter object userFilter:any={name :''}; and i still get EXCEPTION: Error in ./UsersComponent class UsersComponent - inline template:26:19 caused by: Cannot read property 'toLowerCase' of undefined

@VadimDez
Copy link
Owner

VadimDez commented Mar 9, 2017

@dearibujar did you try to put users and userFilter from my example ?
Otherwise, show me your data (make a mock of sensitive data if you want...) and html where you're using filterBy.

@dearibujar
Copy link
Author

@VadimDez I tried with your sample data also, same error. I will provide you also with a mock of my data and the html. But is it maybe the latest angular version that is causing the problem? By the way , i am using angular/cli

@dearibujar
Copy link
Author

I deleted your pipe and installed it from the begining, now it is working. But thank you for taking time, have a nice day.

@alexsalmon
Copy link

This issue is present in the examples, on the first "object.num" input.

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

3 participants