title: Searchbar with filter and from JSON data with Ionic 2
body: <p>I'm very new to Typescript and Ionic 2 and I'm trying to filter trough a json response with Ionic 2 search bar.</p>
  
  <p>This is my code: </p>
  
  <pre><code>import {Component} from '@angular/core';
  import {NavController} from 'ionic-angular';
  import {Http} from '@angular/http';
  import 'rxjs/add/operator/map';
  
  
  
  @Component({
    templateUrl: 'build/pages/home/home.html'
  })
  export class HomePage {
  
    posts: any;
    private searchQuery: string = '';
    private items: string[];
    constructor(private http: Http) {
  
      this.initializeItems();
  
      this.http.get('https://domain.co/open.jsonp').map(res =&gt; res.json()).subscribe(data =&gt; {
          this.posts = data;
          console.log(this.posts);
  
      });
  
    }
  
    initializeItems() {
      this.items = this.posts;
    }
  
    getItems(ev: any) {
      // Reset items back to all of the items
      this.initializeItems();
  
      // set val to the value of the searchbar
      let val = ev.target.value;
  
      // if the value is an empty string don't filter the items
      if (val &amp;&amp; val.trim() != '') {
        this.items = this.items.filter((item) =&gt; {
          return (item.toLowerCase().indexOf(val.toLowerCase()) &gt; -1);
        })
      }
    }
  
  }
  </code></pre>
  
  <p>And the Markup: </p>
  
  <pre><code>&lt;ion-header&gt;
    &lt;ion-searchbar (ionInput)="getItems($event)" [debounce]="500" placeholder="Suchen..."&gt;&lt;/ion-searchbar&gt;
  &lt;/ion-header&gt;
  
  &lt;ion-content&gt;
    &lt;ion-list&gt;
      &lt;ion-item *ngFor="let post of posts"&gt;
        &lt;h1&gt;{{post.storeName}}&lt;/h1&gt;
      &lt;/ion-item&gt;
    &lt;/ion-list&gt;
  &lt;/ion-content&gt;
  </code></pre>
  
  <p>I this error when I search:</p>
  
  <blockquote>
    <p>item.toLowerCase is not a function</p>
  </blockquote>
  
  <p>The JSON data looks like this: </p>
  
  <pre><code>[
  {
  storeName: "Avec Hauptbahnhof",
  addressLink: "",
  phone: "0326223902",
  image: "",
  description: "",
  link: "",
  openingHours: [
  "05.30 - 22:00",
  "05.30 - 22:00",
  "05.30 - 22:00",
  "05.30 - 22:00",
  "05.30 - 22:00",
  "06.30 - 22:00",
  "7.00 - 22.00"
  ]
  },
  {
  storeName: "Manor",
  addressLink: "",
  phone: "0326258699",
  image: "",
  customer: "",
  description: "",
  link: "",
  openingHours: [
  "09.00 - 18.30",
  "09.00 - 18.30",
  "09.00 - 18.30",
  "09.00 - 21:00",
  "09.00 - 18.30",
  "08.00 - 17.00",
  "Geschlossen"
  ]
  }
  ]
  </code></pre>