How do I display a filtered list of BED objects from my BED ARRAY? I just need a simple filter (bStatus = "Available") for loop for reference.
My BED object has a Bed Status, which shows if it's Available or Occupied (for a hospital system), and I want it to display ONLY Beds which are Available. (when bStatus == "Available")
The code provides a part from my NgOnInit() from my component.ts, I'm able to display all the beds available, but as I'm new to Angular and Typescript, I do not know how to add filter into my code.
this.bedService
.query()
.pipe(
filter((mayBeOk: HttpResponse<IBed[]>) => mayBeOk.ok),
map((response: HttpResponse<IBed[]>) => response.body),
)
.subscribe((res: IBed[]) => (this.beds = res), (res: HttpErrorResponse) => this.onError(res.message));
The expected output should be a list of beds which have bStatus = "Available". Right now it displays all the beds in my array, which include bStatus = "Available" and "Occupied".
Aucun commentaire:
Enregistrer un commentaire