Ionic2 searchbar very slow for 1000+ items

Hi!!

I just binded a simple Pipe to an input, like this:

My Input:
<ion-input clearInput type="text" placeholder="Search..." [(ngModel)]="searchQuery"></ion-input>

My ngFor with the pipe:
<button ion-item *ngFor="#contact of contacts | ContactsPipe:searchQuery" class="crazy" ion-chevron-right (click)="goToNewChat(contact)">

My pipe, very simple:

import {Pipe} from ‘angular2/core’;

@Pipe({
  name: 'ContactsPipe'
})
export class ContactsPipe {
  transform(values, args?) {
    let [name] = args;
    if (name === '') return values;
    return values.filter(contact => {
      if (contact.name.formatted.toLowerCase().search(name.toLowerCase()) > -1) {
        return contact;
      }
    })
  }
}

Hope it helps :slight_smile:

1 Like