Comments (12)
@lzm420241, could you show me example of the object?
from ngx-filter-pipe.
@VadimDez my ex array like this:
[{ id: 1, name: "fkds", sub:[ {id:1,name: "dks"} ]} ]
when i input 1, then it show nothing
and i input "f", then it show errMsg "t.toLowerCase is not a function".
from ngx-filter-pipe.
@lzm420241 can you show me what do you pass to filterBy
as well ?
from ngx-filter-pipe.
<label>key:</label><input type="text" [(ngModel)]="stringFilter" >
<li *ngFor="let item of List | filterBy: stringFilter ">
<span>{{ item.name }}</span>
</li>
and list is
[{ id: 1, name: "fkds", sub:[ {id:1,name: "dks"} ]} ]
from ngx-filter-pipe.
You can't filter object with just a string, you need to make stringFilter
object as well, and if you want to filter by name
- you have to make:
stringFIlter = { name: '' }
and in your html instead of [(ngModel)]="stringFilter"
do [(ngModel)]="stringFilter.name"
from ngx-filter-pipe.
@VadimDez thx, it solved problem,but if my html is
<label>key:</label><input type="text" [(ngModel)]="stringFilter" >
<li *ngFor="let item of List | filterBy: stringFilter ">
<span>{{ item.name }}</span>
<ul *ngIf =" item.sub ">
<li *ngFor = " let value of item.sub | filterBy: stringFilter">{{ value.name}}<li>
</ul>
</li>
when i search sub :[name : "dks"], then because of item.name != search.value ,then the it can't show the child of li, i didn't find the API about one conditon for filter mutiple data in ng2-filter-pipe, how to solve this problem?
from ngx-filter-pipe.
Not sure, but maybe something like this ?
<label>key:</label>
<input type="text" [(ngModel)]="stringFilter" >
<li *ngFor="let item of List" *ngIf="(item.sub | filterBy: stringFilter).length">
<span>{{ item.name }}</span>
<ul *ngIf =" item.sub ">
<li *ngFor = " let value of item.sub | filterBy: stringFilter">{{ value.name}}<li>
</ul>
</li>
from ngx-filter-pipe.
@VadimDez *ngFor and *ngIf can't use together!and by this way, it only search for sub :[name : "dks"],right?
from ngx-filter-pipe.
Hi @VadimDez , first thanks for this package, it's great, however I would like to use it filtering multiple values, can you help me on how to use it? this is what I tried:
private stringFilter = { name: '', position: '', city: '' };
<input type="text" [(ngModel)]="stringFilter">
<ul *ngIf="peopleList">
<li *ngFor="let item of peopleList | filterBy: stringFilter">
{{item.name}}, {{item.position}}, {{item.city}}
</li>
</ul>
I want to filter by name, position or city and I don't know how to specify this.
If I set [(ngModel)]="stringFilter.name" it works just for name, how can I cover for the other values?
Thanks for your help.
from ngx-filter-pipe.
@cgowez, you can try to create one input field for each field in your filter.
Something like this:
<input type="text" [(ngModel)]="stringFilter.name" name="name" placeholder="Name">
<input type="text" [(ngModel)]="stringFilter.position" name="position" placeholder="Position">
<input type="text" [(ngModel)]="stringFilter.city" name="city" placeholder="City">
from ngx-filter-pipe.
I thought on that however I don't think it's the best approach for user friendly, I'm thinking to create a new string with those three values, thanks for your quick response.
from ngx-filter-pipe.
hey @VadimDez this is what I did and worked as expected:
I added another value on the JSON response with the other values combined.
.json:
"together": "name position city',
.ts:
private stringFilter = { together: ''};
.html:
<label>Filter: </label><input type="text" [(ngModel)]="stringFilter.together">
<ul *ngIf="peopleList">
<li *ngFor="let item of peopleList | filterBy: stringFilter">
{{item.name}}, {{item.position}}, {{item.city}}
<div style="display: none">{{item.together}}</div>
</li>
</ul>
It works great, thanks.
from ngx-filter-pipe.
Related Issues (20)
- How to return Nested null objects
- How do I filter by more than one field HOT 2
- <select> value 0 is not filtering underlying table
- Impossible to use in Angular 16 HOT 3
- Checking for empty return values HOT 1
- Filtering Array with null Nested Objects
- I am getting "The pipe 'filterBy' could not be found" HOT 3
- Select nothing instead of all when $or list is empty
- Use filter with Date HOT 2
- Pipe perfomance issue HOT 1
- Any chance an $and can be implemented?
- Filter by regex
- Application gets stuck each time.
- Upgrade to Angular 8
- possibility to have pure pipe for performance issues
- Angular 7.1.2 Build: Function calls are not supported in decorators but 'ɵmakeDecorator' was called in 'NgModule'
- An in-range update of ts-node is breaking the build 🚨 HOT 6
- How can i return full name by concatenating first name and last name.
- An in-range update of core-js is breaking the build 🚨 HOT 5
- An in-range update of @types/node is breaking the build 🚨 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngx-filter-pipe.