I get data from backend with this function
private loaddata(): void { this.dataService.loaddata().pipe( tap((response: any) => { this.persons = response.results; this.personmembertrue = this.persons.filter(x => x.is_family_member === 'false') }), takeUntil(this.onComponentDestroy) ).subscribe(); }
and console.log(response)
show JSON like below
{ "count": 38, "next": null, "previous": null, "results": [ { "id": 113, "foreigner": false, "outside_community": false, "nipt": "", "nid": "G45675570K", "is_family_member": true }, { "id": 115, "foreigner": false, "outside_community": false, "nipt": "", "nid": "K30776771A", "is_family_member": false }, { "id": 116, "foreigner": false, "outside_community": false, "nipt": "", "nid": "J305070577", "is_family_member": false }... ] }
What I want are data that have "is_family_member": false
, for this I create this.personmembertrue = this.persons.filter(x => x.is_family_member === 'false')
this part of code show empty.
Any idea please how to show data with "is_family_member": false
Advertisement
Answer
Change the condition to:
this.personmembertrue = this.persons.filter(x => x.is_family_member === false);
See if that works.