I get data from backend with this function
JavaScript
x
10
10
1
private loaddata(): void {
2
this.dataService.loaddata().pipe(
3
tap((response: any) => {
4
this.persons = response.results;
5
this.personmembertrue = this.persons.filter(x => x.is_family_member === 'false')
6
}),
7
takeUntil(this.onComponentDestroy)
8
).subscribe();
9
}
10
and console.log(response)
show JSON like below
JavaScript
1
32
32
1
{
2
"count": 38,
3
"next": null,
4
"previous": null,
5
"results": [
6
{
7
"id": 113,
8
"foreigner": false,
9
"outside_community": false,
10
"nipt": "",
11
"nid": "G45675570K",
12
"is_family_member": true
13
},
14
{
15
"id": 115,
16
"foreigner": false,
17
"outside_community": false,
18
"nipt": "",
19
"nid": "K30776771A",
20
"is_family_member": false
21
},
22
{
23
"id": 116,
24
"foreigner": false,
25
"outside_community": false,
26
"nipt": "",
27
"nid": "J305070577",
28
"is_family_member": false
29
}
30
]
31
}
32
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:
JavaScript
1
2
1
this.personmembertrue = this.persons.filter(x => x.is_family_member === false);
2
See if that works.