ionic5 filter with all columns in array
npm i ng2-search-filter -->install
import { Ng2SearchPipeModule } from 'ng2-search-filter';
Ng2SearchPipeModule
import in app module
add Ng2SearchPipeModule to page module-->
<ion-header>
<ion-toolbar>
<ion-title>Ionic Search</ion-title>
</ion-toolbar>
</ion-header>
<ion-content class="ion-padding">
<!-- Search Bar -->
<ion-searchbar placeholder="Filter Schedules" [(ngModel)]="term" animated="true"></ion-searchbar>
<!-- List Items -->
<ion-list>
<ion-item *ngFor="let item of filterData | filter:term">
<ion-label>{{item.firstName}} {{item.lastName}}</ion-label>
</ion-item>
</ion-list>
</ion-content>
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-search',
templateUrl: './search.page.html',
styleUrls: ['./search.page.scss'],
})
export class SearchPage implements OnInit {
term = '';
filterData = [
{
firstName: 'Celestine',
lastName: 'Schimmel',
address: '7687 Jadon Port'
},
{
firstName: 'Johan',
lastName: 'Ziemann PhD',
address: '156 Streich Ports'
},
{
firstName: 'Lizzie',
lastName: 'Schumm',
address: '5203 Jordon Center'
},
{
firstName: 'Gavin',
lastName: 'Leannon',
address: '91057 Davion Club'
},
{
firstName: 'Lucious',
lastName: 'Leuschke',
address: '16288 Reichel Harbor'
}
]
constructor() { }
ngOnInit() {
}
}
Comments
Post a Comment