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

Popular posts from this blog

Your app currently targets API level 27 and must target at least API level 28 to ensure it is built on the latest APIs optimized for security and performance. Change your app's target API level to at least 28

ionic project creation

change root user in ubuntu