<ion-item *ngFor="let contact of contacts | isMember">
<ion-label>{{contact.name}}</ion-label>
{{contact.phoneNumber}}-{{contact.isMember}}
</ion-item>
Filter definition below:import { Pipe, PipeTransform } from '@angular/core';
@Pipe({name: 'isMember'})
export class IsMemberPipe implements PipeTransform {
transform(value: any): any {
if (value.isMember === true) {
return value;
}
return undefined;
}
}
-----
Question
Goal is to only display rows that have isMember flag set to true.------
Answers
Just ensure your pipe doesn't explode when
null
is passed in as valueif (value && value.isMember === true) {
0 nhận xét:
Post a Comment