I have a data as follows:
tasks= [
{
"id":8,
"title":"Eight",
"how_often":"DS",
"how_important_task":"",
"how_important_improvement":"",
"stakeholder":2,
"project":2
},
{
"id":9,
"title":"Nine",
"how_often":"",
"how_important_task":"",
"how_important_improvement":"",
"stakeholder":2,
"project":2
},
{
"id":21,
"title":"Seventeen",
"how_often":"",
"how_important_task":"",
"how_important_improvement":"",
"stakeholder":2,
"project":2
}
]
I have two models and a method in my component:
public how_important_task: string= "";
public how_often: string = "";
applyFilters(){
this.tasks = this.tasks.filter(task => {})
}
And template with filters and list:
<ion-select [(ngModel)]="how_often" (ionChange)="applyFilters()">
<ion-option value="">None</ion-option>
<ion-option *ngFor="let frequency of filer_per_frequency" value="{{frequency.value}}">{{frequency.title}}</ion-option>
</ion-select>
<ion-select [(ngModel)]="how_important_task" (ionChange)="applyFilters()">
<ion-option *ngFor="let importance of filer_per_importance" value="{{importance.value}}">{{importance.title}}</ion-option>
</ion-select>
...
<ion-list>
<button detail-none (click)="expandItem(task)" ion-item *ngFor="let task of tasks">
<h2>{{task.title}}</h2>
<expandable [expandHeight]="itemExpandHeight" [expanded]="task.expanded">
<hr><p>{{task.how_often | fullform}}</p>
<p>{{task.how_important_task | fullform}}</p>
<p>{{task.why_perform_task}}</p>
<p>{{task.sequence_of_actions}}</p>
</expandable>
</button>
</ion-list>
In my method I want to apply all selected filters on my Tasks. How can I achieve that?
this.tasks.filter(task => {})?