Home > OS >  How to filter data in angular 14
How to filter data in angular 14

Time:08-11

How do I edit my "status" and "step" filter functions? thank

this.prhd.getPr_prhds().subscribe({
   next: data => { 
        this.dataSource.data = data.filter(s => s.status == 'O' && a => a.step== '01' )
    }

I want a display with status o and step 01 to be displayed on the web.

[{
"id": 1,
"name": "aaaa",
"status": "O",
"step": "01",
},
{
"id": 2,
"name": "bbbb",
"status": "O",
"step": "01",
},
{
"id": 3,
"name": "cccc",
"status": "O",
"step": "02",
},
{
"id": 4,
"name": "dddd",
"status": "O",
"step": "02",
}]

CodePudding user response:

Just update the filter function like this:

data.filter(s => s.status === 'O' && s.step === '01');
  • Related