I have a list of statuses whose values are: Dispatched, open, and closed. When I click on a checkbox I want to filter the results
<ion-item *ngFor="let s of appointmentStatus" >
<ion-checkbox [(ngModel)]="s.checked" (click)="updateFilter(s)"></ion-checkbox>
<ion-label >{{ s.status }}</ion-label>
</ion-item>
<div *ngFor="let a of todaysAppointments>
//list of appointments goes here
I have tried to come up with a way to do this with pipes, but I have not found a good example and I am rather new. Any help would be appreciated.
if ((appDate.getDay() == currentDate.getDay()) && (appDate.getMonth() == currentDate.getMonth()) && (appDate.getFullYear() == currentDate.getFullYear()) && this.appointments[i].status != 'Pending') {
this.todaysAppointments.push(this.appointments[i]);
}
if ((appDate.getDay() < currentDate.getDay()) && (appDate.getMonth() >= currentDate.getMonth()) && (appDate.getFullYear() >= currentDate.getFullYear()) && this.appointments[i].status != 'Pending') {
this.upcomingAppointments.push(this.appointments[i]);
}
So what you did below works perfect when you only have a single array. On my html I have it divided up into Todays and upcoming appointments. So I first have the page load and show all the appointments in there corresponding sections. Then on top of that I want to filter by the checkboxes.
<h2 style="background-color:#387ef5">Today's Appointments</h2>
<div *ngFor="let a of todaysAppointments | filter: searchTerm" (click)="openPage(a)">
<h2 style="background-color:#387ef5">Upcoming Appointments</h2>
<div *ngFor="let a of upcomingAppointments | filter: searchTerm" (click)="openPage(a)">