How to use this pipe with another one in this code for filtering the data in Angular?












1















I've added to form inputs that will filter users by age ranges. Created pipe for that. Now I am trying to implement that in the working example where were used other pipe for filtering results based on other forms. How can I use age range pipe in this working example and make those 2 pipes work together? Here is the code:



Age range pipe



     transform(value: any, args?: any): any
{ if(!args) return value;
return value.filter( item => item.age > args[0] && item => item.age < args[1])
);
}


Where args[0] is min value and args[1] max value.



Pipe of working search example



import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'filter',
})
export class FilterPipe implements PipeTransform {
transform(items: any, value: string, prop: string): any {
if (!items) return ;
if (!value) return items;

return items.filter(singleItem =>
singleItem[prop].toLowerCase().includes(value.toLowerCase())
);

}
}


TypeScript of working example



form: FormGroup;

@Output() autoSearch: EventEmitter<string> = new EventEmitter<string>();
@Output() groupFilters: EventEmitter<any> = new EventEmitter<any>();
searchText: string = '';
constructor(private fb: FormBuilder,
private userService: UserService) {}

ngOnInit(): void {
this.buildForm();
}

buildForm(): void {
this.form = this.fb.group({
name: new FormControl(''),
prefix: new FormControl(''),
position: new FormControl(''),
gender: new FormControl(''),
agefrom: new FormControl(''),
ageto: new FormControl('')
});
}

search(filters: any): void {
Object.keys(filters).forEach(key => filters[key] === '' ? delete filters[key] : key);
this.groupFilters.emit(filters);
}

}


HTML



<form novalidate
[formGroup]="form">

<h3>Group Filter</h3>
<div class="row">
<div class="col-md-3">
<input type="text"
formControlName="name"
class="form-control"
placeholder="name"
#searchName
/>
</div>
<div class="col-md-3">
<input type="text"
formControlName="agefrom"
class="form-control"
placeholder="age from"
#searchName
/>
</div>
<div class="col-md-3">
<input type="text"
formControlName="nageto"
class="form-control"
placeholder="age to"
#searchName
/>
</div>
<div class="col-md-3 col-sm-3">
<select class="form-control"
formControlName="prefix">
<option value="">Prefix</option>
<option value="MR">MR</option>
<option value="MS">MS</option>
</select>
</div>

<div class="col-md-3 col-sm-3">
<select class="form-control"
formControlName="position">
<option value="">Position</option>
<option value="admin">admin</option>
<option value="student">student</option>
</select>
</div>

<div class="col-md-3 col-sm-3">
<select class="form-control"
formControlName="gender">
<option value="">Gender</option>
<option value="M">male</option>
<option value="F">female</option>
</select>
</div>

<div class="col-md-3 col-sm-3">
<button class="btn btn-primary"
(click)="search(form.value)">Search</button>
</div>
</div>

</form><br/>


For the full code example you can check here:
https://stackblitz.com/edit/ng6-multiple-search-values-smz1cb-solved-jx6kgc?file=src%2Fapp%2Fuser%2Ffilter.pipe.ts



How can I implement that age range pipe in the code and make it the part of this working example?










share|improve this question

























  • You can achieve this by using two separate filters, else you need to work on generic filter. let me know what you want to achieve. like complexity vs simplicity.

    – AlokeT
    Nov 23 '18 at 10:06











  • I need just any simple way to make this age range inputs filters work as good as other ones do. The only challenge is implementing that age range inputs filter in the mentioned working example and make it work.

    – NewTech Lover
    Nov 23 '18 at 10:20
















1















I've added to form inputs that will filter users by age ranges. Created pipe for that. Now I am trying to implement that in the working example where were used other pipe for filtering results based on other forms. How can I use age range pipe in this working example and make those 2 pipes work together? Here is the code:



Age range pipe



     transform(value: any, args?: any): any
{ if(!args) return value;
return value.filter( item => item.age > args[0] && item => item.age < args[1])
);
}


Where args[0] is min value and args[1] max value.



Pipe of working search example



import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'filter',
})
export class FilterPipe implements PipeTransform {
transform(items: any, value: string, prop: string): any {
if (!items) return ;
if (!value) return items;

return items.filter(singleItem =>
singleItem[prop].toLowerCase().includes(value.toLowerCase())
);

}
}


TypeScript of working example



form: FormGroup;

@Output() autoSearch: EventEmitter<string> = new EventEmitter<string>();
@Output() groupFilters: EventEmitter<any> = new EventEmitter<any>();
searchText: string = '';
constructor(private fb: FormBuilder,
private userService: UserService) {}

ngOnInit(): void {
this.buildForm();
}

buildForm(): void {
this.form = this.fb.group({
name: new FormControl(''),
prefix: new FormControl(''),
position: new FormControl(''),
gender: new FormControl(''),
agefrom: new FormControl(''),
ageto: new FormControl('')
});
}

search(filters: any): void {
Object.keys(filters).forEach(key => filters[key] === '' ? delete filters[key] : key);
this.groupFilters.emit(filters);
}

}


HTML



<form novalidate
[formGroup]="form">

<h3>Group Filter</h3>
<div class="row">
<div class="col-md-3">
<input type="text"
formControlName="name"
class="form-control"
placeholder="name"
#searchName
/>
</div>
<div class="col-md-3">
<input type="text"
formControlName="agefrom"
class="form-control"
placeholder="age from"
#searchName
/>
</div>
<div class="col-md-3">
<input type="text"
formControlName="nageto"
class="form-control"
placeholder="age to"
#searchName
/>
</div>
<div class="col-md-3 col-sm-3">
<select class="form-control"
formControlName="prefix">
<option value="">Prefix</option>
<option value="MR">MR</option>
<option value="MS">MS</option>
</select>
</div>

<div class="col-md-3 col-sm-3">
<select class="form-control"
formControlName="position">
<option value="">Position</option>
<option value="admin">admin</option>
<option value="student">student</option>
</select>
</div>

<div class="col-md-3 col-sm-3">
<select class="form-control"
formControlName="gender">
<option value="">Gender</option>
<option value="M">male</option>
<option value="F">female</option>
</select>
</div>

<div class="col-md-3 col-sm-3">
<button class="btn btn-primary"
(click)="search(form.value)">Search</button>
</div>
</div>

</form><br/>


For the full code example you can check here:
https://stackblitz.com/edit/ng6-multiple-search-values-smz1cb-solved-jx6kgc?file=src%2Fapp%2Fuser%2Ffilter.pipe.ts



How can I implement that age range pipe in the code and make it the part of this working example?










share|improve this question

























  • You can achieve this by using two separate filters, else you need to work on generic filter. let me know what you want to achieve. like complexity vs simplicity.

    – AlokeT
    Nov 23 '18 at 10:06











  • I need just any simple way to make this age range inputs filters work as good as other ones do. The only challenge is implementing that age range inputs filter in the mentioned working example and make it work.

    – NewTech Lover
    Nov 23 '18 at 10:20














1












1








1








I've added to form inputs that will filter users by age ranges. Created pipe for that. Now I am trying to implement that in the working example where were used other pipe for filtering results based on other forms. How can I use age range pipe in this working example and make those 2 pipes work together? Here is the code:



Age range pipe



     transform(value: any, args?: any): any
{ if(!args) return value;
return value.filter( item => item.age > args[0] && item => item.age < args[1])
);
}


Where args[0] is min value and args[1] max value.



Pipe of working search example



import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'filter',
})
export class FilterPipe implements PipeTransform {
transform(items: any, value: string, prop: string): any {
if (!items) return ;
if (!value) return items;

return items.filter(singleItem =>
singleItem[prop].toLowerCase().includes(value.toLowerCase())
);

}
}


TypeScript of working example



form: FormGroup;

@Output() autoSearch: EventEmitter<string> = new EventEmitter<string>();
@Output() groupFilters: EventEmitter<any> = new EventEmitter<any>();
searchText: string = '';
constructor(private fb: FormBuilder,
private userService: UserService) {}

ngOnInit(): void {
this.buildForm();
}

buildForm(): void {
this.form = this.fb.group({
name: new FormControl(''),
prefix: new FormControl(''),
position: new FormControl(''),
gender: new FormControl(''),
agefrom: new FormControl(''),
ageto: new FormControl('')
});
}

search(filters: any): void {
Object.keys(filters).forEach(key => filters[key] === '' ? delete filters[key] : key);
this.groupFilters.emit(filters);
}

}


HTML



<form novalidate
[formGroup]="form">

<h3>Group Filter</h3>
<div class="row">
<div class="col-md-3">
<input type="text"
formControlName="name"
class="form-control"
placeholder="name"
#searchName
/>
</div>
<div class="col-md-3">
<input type="text"
formControlName="agefrom"
class="form-control"
placeholder="age from"
#searchName
/>
</div>
<div class="col-md-3">
<input type="text"
formControlName="nageto"
class="form-control"
placeholder="age to"
#searchName
/>
</div>
<div class="col-md-3 col-sm-3">
<select class="form-control"
formControlName="prefix">
<option value="">Prefix</option>
<option value="MR">MR</option>
<option value="MS">MS</option>
</select>
</div>

<div class="col-md-3 col-sm-3">
<select class="form-control"
formControlName="position">
<option value="">Position</option>
<option value="admin">admin</option>
<option value="student">student</option>
</select>
</div>

<div class="col-md-3 col-sm-3">
<select class="form-control"
formControlName="gender">
<option value="">Gender</option>
<option value="M">male</option>
<option value="F">female</option>
</select>
</div>

<div class="col-md-3 col-sm-3">
<button class="btn btn-primary"
(click)="search(form.value)">Search</button>
</div>
</div>

</form><br/>


For the full code example you can check here:
https://stackblitz.com/edit/ng6-multiple-search-values-smz1cb-solved-jx6kgc?file=src%2Fapp%2Fuser%2Ffilter.pipe.ts



How can I implement that age range pipe in the code and make it the part of this working example?










share|improve this question
















I've added to form inputs that will filter users by age ranges. Created pipe for that. Now I am trying to implement that in the working example where were used other pipe for filtering results based on other forms. How can I use age range pipe in this working example and make those 2 pipes work together? Here is the code:



Age range pipe



     transform(value: any, args?: any): any
{ if(!args) return value;
return value.filter( item => item.age > args[0] && item => item.age < args[1])
);
}


Where args[0] is min value and args[1] max value.



Pipe of working search example



import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'filter',
})
export class FilterPipe implements PipeTransform {
transform(items: any, value: string, prop: string): any {
if (!items) return ;
if (!value) return items;

return items.filter(singleItem =>
singleItem[prop].toLowerCase().includes(value.toLowerCase())
);

}
}


TypeScript of working example



form: FormGroup;

@Output() autoSearch: EventEmitter<string> = new EventEmitter<string>();
@Output() groupFilters: EventEmitter<any> = new EventEmitter<any>();
searchText: string = '';
constructor(private fb: FormBuilder,
private userService: UserService) {}

ngOnInit(): void {
this.buildForm();
}

buildForm(): void {
this.form = this.fb.group({
name: new FormControl(''),
prefix: new FormControl(''),
position: new FormControl(''),
gender: new FormControl(''),
agefrom: new FormControl(''),
ageto: new FormControl('')
});
}

search(filters: any): void {
Object.keys(filters).forEach(key => filters[key] === '' ? delete filters[key] : key);
this.groupFilters.emit(filters);
}

}


HTML



<form novalidate
[formGroup]="form">

<h3>Group Filter</h3>
<div class="row">
<div class="col-md-3">
<input type="text"
formControlName="name"
class="form-control"
placeholder="name"
#searchName
/>
</div>
<div class="col-md-3">
<input type="text"
formControlName="agefrom"
class="form-control"
placeholder="age from"
#searchName
/>
</div>
<div class="col-md-3">
<input type="text"
formControlName="nageto"
class="form-control"
placeholder="age to"
#searchName
/>
</div>
<div class="col-md-3 col-sm-3">
<select class="form-control"
formControlName="prefix">
<option value="">Prefix</option>
<option value="MR">MR</option>
<option value="MS">MS</option>
</select>
</div>

<div class="col-md-3 col-sm-3">
<select class="form-control"
formControlName="position">
<option value="">Position</option>
<option value="admin">admin</option>
<option value="student">student</option>
</select>
</div>

<div class="col-md-3 col-sm-3">
<select class="form-control"
formControlName="gender">
<option value="">Gender</option>
<option value="M">male</option>
<option value="F">female</option>
</select>
</div>

<div class="col-md-3 col-sm-3">
<button class="btn btn-primary"
(click)="search(form.value)">Search</button>
</div>
</div>

</form><br/>


For the full code example you can check here:
https://stackblitz.com/edit/ng6-multiple-search-values-smz1cb-solved-jx6kgc?file=src%2Fapp%2Fuser%2Ffilter.pipe.ts



How can I implement that age range pipe in the code and make it the part of this working example?







angular angular6






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 16:21







NewTech Lover

















asked Nov 23 '18 at 9:37









NewTech LoverNewTech Lover

134312




134312













  • You can achieve this by using two separate filters, else you need to work on generic filter. let me know what you want to achieve. like complexity vs simplicity.

    – AlokeT
    Nov 23 '18 at 10:06











  • I need just any simple way to make this age range inputs filters work as good as other ones do. The only challenge is implementing that age range inputs filter in the mentioned working example and make it work.

    – NewTech Lover
    Nov 23 '18 at 10:20



















  • You can achieve this by using two separate filters, else you need to work on generic filter. let me know what you want to achieve. like complexity vs simplicity.

    – AlokeT
    Nov 23 '18 at 10:06











  • I need just any simple way to make this age range inputs filters work as good as other ones do. The only challenge is implementing that age range inputs filter in the mentioned working example and make it work.

    – NewTech Lover
    Nov 23 '18 at 10:20

















You can achieve this by using two separate filters, else you need to work on generic filter. let me know what you want to achieve. like complexity vs simplicity.

– AlokeT
Nov 23 '18 at 10:06





You can achieve this by using two separate filters, else you need to work on generic filter. let me know what you want to achieve. like complexity vs simplicity.

– AlokeT
Nov 23 '18 at 10:06













I need just any simple way to make this age range inputs filters work as good as other ones do. The only challenge is implementing that age range inputs filter in the mentioned working example and make it work.

– NewTech Lover
Nov 23 '18 at 10:20





I need just any simple way to make this age range inputs filters work as good as other ones do. The only challenge is implementing that age range inputs filter in the mentioned working example and make it work.

– NewTech Lover
Nov 23 '18 at 10:20












1 Answer
1






active

oldest

votes


















2














I solve your problem but without using pipes I make the logic in the filter function you made in the (user-list.component.ts) you can check it here :



https://stackblitz.com/edit/ng6-multiple-search-values-smz1cb-solved-age-range?file=src%2Fapp%2Fuser%2Fuser-list%2Fuser-list.component.html



Hope my answer help you






share|improve this answer
























  • Thank you so much! It works perfectly. Just one question. When I remove <th> and <td> for name or age inputs search still works which is great but when I remove <th> and <td> for those data that were used with select filters it doesn't filter anymore? What's the difference for those ones? I am asking it because in the real app not all dates from backend should be displayed on the screen but search should work. It's very interesting case that happens only for select.

    – NewTech Lover
    Nov 23 '18 at 15:26













  • I think is because when filter function executes it give you an error when make the check of the user['age'] because of the empty field but I add a safe type checking now in the code and make a sample with the case when age is not sent and the filters works again!

    – Shorbagy
    Nov 23 '18 at 15:33











  • Nope. I mean age and name were worked perfectly when the <Td> and <th> were not there. That trouble is with gender, prefix and another one which are selects instead of inputs.

    – NewTech Lover
    Nov 23 '18 at 15:35











  • I know the problem because of in keys filters I don't make a safe checking for them and also if they aren't in obj so we append false to the result array I updated the stackblitz with the new solution with an example which meets your case

    – Shorbagy
    Nov 23 '18 at 15:50











  • It seems I can't explain enough well. It's not the case :D You just added conditions in HTML part. Here is what exactly I want to explain: stackblitz.com/edit/… I removed name and prefix fully. But when you search by name it works which is correct. When you select from prefix it doesn't work. For the name, it gets data from backend correctly. But for a prefix which is select, it doesn't.

    – NewTech Lover
    Nov 23 '18 at 16:07












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53444031%2fhow-to-use-this-pipe-with-another-one-in-this-code-for-filtering-the-data-in-ang%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














I solve your problem but without using pipes I make the logic in the filter function you made in the (user-list.component.ts) you can check it here :



https://stackblitz.com/edit/ng6-multiple-search-values-smz1cb-solved-age-range?file=src%2Fapp%2Fuser%2Fuser-list%2Fuser-list.component.html



Hope my answer help you






share|improve this answer
























  • Thank you so much! It works perfectly. Just one question. When I remove <th> and <td> for name or age inputs search still works which is great but when I remove <th> and <td> for those data that were used with select filters it doesn't filter anymore? What's the difference for those ones? I am asking it because in the real app not all dates from backend should be displayed on the screen but search should work. It's very interesting case that happens only for select.

    – NewTech Lover
    Nov 23 '18 at 15:26













  • I think is because when filter function executes it give you an error when make the check of the user['age'] because of the empty field but I add a safe type checking now in the code and make a sample with the case when age is not sent and the filters works again!

    – Shorbagy
    Nov 23 '18 at 15:33











  • Nope. I mean age and name were worked perfectly when the <Td> and <th> were not there. That trouble is with gender, prefix and another one which are selects instead of inputs.

    – NewTech Lover
    Nov 23 '18 at 15:35











  • I know the problem because of in keys filters I don't make a safe checking for them and also if they aren't in obj so we append false to the result array I updated the stackblitz with the new solution with an example which meets your case

    – Shorbagy
    Nov 23 '18 at 15:50











  • It seems I can't explain enough well. It's not the case :D You just added conditions in HTML part. Here is what exactly I want to explain: stackblitz.com/edit/… I removed name and prefix fully. But when you search by name it works which is correct. When you select from prefix it doesn't work. For the name, it gets data from backend correctly. But for a prefix which is select, it doesn't.

    – NewTech Lover
    Nov 23 '18 at 16:07
















2














I solve your problem but without using pipes I make the logic in the filter function you made in the (user-list.component.ts) you can check it here :



https://stackblitz.com/edit/ng6-multiple-search-values-smz1cb-solved-age-range?file=src%2Fapp%2Fuser%2Fuser-list%2Fuser-list.component.html



Hope my answer help you






share|improve this answer
























  • Thank you so much! It works perfectly. Just one question. When I remove <th> and <td> for name or age inputs search still works which is great but when I remove <th> and <td> for those data that were used with select filters it doesn't filter anymore? What's the difference for those ones? I am asking it because in the real app not all dates from backend should be displayed on the screen but search should work. It's very interesting case that happens only for select.

    – NewTech Lover
    Nov 23 '18 at 15:26













  • I think is because when filter function executes it give you an error when make the check of the user['age'] because of the empty field but I add a safe type checking now in the code and make a sample with the case when age is not sent and the filters works again!

    – Shorbagy
    Nov 23 '18 at 15:33











  • Nope. I mean age and name were worked perfectly when the <Td> and <th> were not there. That trouble is with gender, prefix and another one which are selects instead of inputs.

    – NewTech Lover
    Nov 23 '18 at 15:35











  • I know the problem because of in keys filters I don't make a safe checking for them and also if they aren't in obj so we append false to the result array I updated the stackblitz with the new solution with an example which meets your case

    – Shorbagy
    Nov 23 '18 at 15:50











  • It seems I can't explain enough well. It's not the case :D You just added conditions in HTML part. Here is what exactly I want to explain: stackblitz.com/edit/… I removed name and prefix fully. But when you search by name it works which is correct. When you select from prefix it doesn't work. For the name, it gets data from backend correctly. But for a prefix which is select, it doesn't.

    – NewTech Lover
    Nov 23 '18 at 16:07














2












2








2







I solve your problem but without using pipes I make the logic in the filter function you made in the (user-list.component.ts) you can check it here :



https://stackblitz.com/edit/ng6-multiple-search-values-smz1cb-solved-age-range?file=src%2Fapp%2Fuser%2Fuser-list%2Fuser-list.component.html



Hope my answer help you






share|improve this answer













I solve your problem but without using pipes I make the logic in the filter function you made in the (user-list.component.ts) you can check it here :



https://stackblitz.com/edit/ng6-multiple-search-values-smz1cb-solved-age-range?file=src%2Fapp%2Fuser%2Fuser-list%2Fuser-list.component.html



Hope my answer help you







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 23 '18 at 15:11









ShorbagyShorbagy

1813




1813













  • Thank you so much! It works perfectly. Just one question. When I remove <th> and <td> for name or age inputs search still works which is great but when I remove <th> and <td> for those data that were used with select filters it doesn't filter anymore? What's the difference for those ones? I am asking it because in the real app not all dates from backend should be displayed on the screen but search should work. It's very interesting case that happens only for select.

    – NewTech Lover
    Nov 23 '18 at 15:26













  • I think is because when filter function executes it give you an error when make the check of the user['age'] because of the empty field but I add a safe type checking now in the code and make a sample with the case when age is not sent and the filters works again!

    – Shorbagy
    Nov 23 '18 at 15:33











  • Nope. I mean age and name were worked perfectly when the <Td> and <th> were not there. That trouble is with gender, prefix and another one which are selects instead of inputs.

    – NewTech Lover
    Nov 23 '18 at 15:35











  • I know the problem because of in keys filters I don't make a safe checking for them and also if they aren't in obj so we append false to the result array I updated the stackblitz with the new solution with an example which meets your case

    – Shorbagy
    Nov 23 '18 at 15:50











  • It seems I can't explain enough well. It's not the case :D You just added conditions in HTML part. Here is what exactly I want to explain: stackblitz.com/edit/… I removed name and prefix fully. But when you search by name it works which is correct. When you select from prefix it doesn't work. For the name, it gets data from backend correctly. But for a prefix which is select, it doesn't.

    – NewTech Lover
    Nov 23 '18 at 16:07



















  • Thank you so much! It works perfectly. Just one question. When I remove <th> and <td> for name or age inputs search still works which is great but when I remove <th> and <td> for those data that were used with select filters it doesn't filter anymore? What's the difference for those ones? I am asking it because in the real app not all dates from backend should be displayed on the screen but search should work. It's very interesting case that happens only for select.

    – NewTech Lover
    Nov 23 '18 at 15:26













  • I think is because when filter function executes it give you an error when make the check of the user['age'] because of the empty field but I add a safe type checking now in the code and make a sample with the case when age is not sent and the filters works again!

    – Shorbagy
    Nov 23 '18 at 15:33











  • Nope. I mean age and name were worked perfectly when the <Td> and <th> were not there. That trouble is with gender, prefix and another one which are selects instead of inputs.

    – NewTech Lover
    Nov 23 '18 at 15:35











  • I know the problem because of in keys filters I don't make a safe checking for them and also if they aren't in obj so we append false to the result array I updated the stackblitz with the new solution with an example which meets your case

    – Shorbagy
    Nov 23 '18 at 15:50











  • It seems I can't explain enough well. It's not the case :D You just added conditions in HTML part. Here is what exactly I want to explain: stackblitz.com/edit/… I removed name and prefix fully. But when you search by name it works which is correct. When you select from prefix it doesn't work. For the name, it gets data from backend correctly. But for a prefix which is select, it doesn't.

    – NewTech Lover
    Nov 23 '18 at 16:07

















Thank you so much! It works perfectly. Just one question. When I remove <th> and <td> for name or age inputs search still works which is great but when I remove <th> and <td> for those data that were used with select filters it doesn't filter anymore? What's the difference for those ones? I am asking it because in the real app not all dates from backend should be displayed on the screen but search should work. It's very interesting case that happens only for select.

– NewTech Lover
Nov 23 '18 at 15:26







Thank you so much! It works perfectly. Just one question. When I remove <th> and <td> for name or age inputs search still works which is great but when I remove <th> and <td> for those data that were used with select filters it doesn't filter anymore? What's the difference for those ones? I am asking it because in the real app not all dates from backend should be displayed on the screen but search should work. It's very interesting case that happens only for select.

– NewTech Lover
Nov 23 '18 at 15:26















I think is because when filter function executes it give you an error when make the check of the user['age'] because of the empty field but I add a safe type checking now in the code and make a sample with the case when age is not sent and the filters works again!

– Shorbagy
Nov 23 '18 at 15:33





I think is because when filter function executes it give you an error when make the check of the user['age'] because of the empty field but I add a safe type checking now in the code and make a sample with the case when age is not sent and the filters works again!

– Shorbagy
Nov 23 '18 at 15:33













Nope. I mean age and name were worked perfectly when the <Td> and <th> were not there. That trouble is with gender, prefix and another one which are selects instead of inputs.

– NewTech Lover
Nov 23 '18 at 15:35





Nope. I mean age and name were worked perfectly when the <Td> and <th> were not there. That trouble is with gender, prefix and another one which are selects instead of inputs.

– NewTech Lover
Nov 23 '18 at 15:35













I know the problem because of in keys filters I don't make a safe checking for them and also if they aren't in obj so we append false to the result array I updated the stackblitz with the new solution with an example which meets your case

– Shorbagy
Nov 23 '18 at 15:50





I know the problem because of in keys filters I don't make a safe checking for them and also if they aren't in obj so we append false to the result array I updated the stackblitz with the new solution with an example which meets your case

– Shorbagy
Nov 23 '18 at 15:50













It seems I can't explain enough well. It's not the case :D You just added conditions in HTML part. Here is what exactly I want to explain: stackblitz.com/edit/… I removed name and prefix fully. But when you search by name it works which is correct. When you select from prefix it doesn't work. For the name, it gets data from backend correctly. But for a prefix which is select, it doesn't.

– NewTech Lover
Nov 23 '18 at 16:07





It seems I can't explain enough well. It's not the case :D You just added conditions in HTML part. Here is what exactly I want to explain: stackblitz.com/edit/… I removed name and prefix fully. But when you search by name it works which is correct. When you select from prefix it doesn't work. For the name, it gets data from backend correctly. But for a prefix which is select, it doesn't.

– NewTech Lover
Nov 23 '18 at 16:07




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53444031%2fhow-to-use-this-pipe-with-another-one-in-this-code-for-filtering-the-data-in-ang%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown