From ff0693fe65c72680f80b3aa39303f20b3a1dbd96 Mon Sep 17 00:00:00 2001 From: Brandy Carney Date: Tue, 5 Jan 2016 19:48:19 -0500 Subject: [PATCH] test(searchbar): added some code to the searchbar nav test based on the docs --- ionic/components/searchbar/test/nav/index.ts | 65 +++++++++++++++++++ .../components/searchbar/test/nav/second.html | 8 ++- 2 files changed, 71 insertions(+), 2 deletions(-) diff --git a/ionic/components/searchbar/test/nav/index.ts b/ionic/components/searchbar/test/nav/index.ts index 5ff4125565..44046163c4 100644 --- a/ionic/components/searchbar/test/nav/index.ts +++ b/ionic/components/searchbar/test/nav/index.ts @@ -17,7 +17,72 @@ class FirstPage { templateUrl: 'second.html' }) class SecondPage { + constructor() { + this.searchQuery = ''; + this.initializeItems(); + } + initializeItems() { + this.items = [ + 'Amsterdam', + 'Bogota', + 'Buenos Aires', + 'Cairo', + 'Dhaka', + 'Edinburgh', + 'Geneva', + 'Genoa', + 'Glasglow', + 'Hanoi', + 'Hong Kong', + 'Islamabad', + 'Istanbul', + 'Jakarta', + 'Kiel', + 'Kyoto', + 'Le Havre', + 'Lebanon', + 'Lhasa', + 'Lima', + 'London', + 'Los Angeles', + 'Madrid', + 'Manila', + 'New York', + 'Olympia', + 'Oslo', + 'Panama City', + 'Peking', + 'Philadelphia', + 'San Francisco', + 'Seoul', + 'Taipeh', + 'Tel Aviv', + 'Tokio', + 'Uelzen', + 'Washington' + ]; + } + + getItems(searchbar) { + // Reset items back to all of the items + this.initializeItems(); + + // set q to the value of the searchbar + var q = searchbar.value; + + // if the value is an empty string don't filter the items + if (q.trim() == '') { + return; + } + + this.items = this.items.filter((v) => { + if (v.toLowerCase().indexOf(q.toLowerCase()) > -1) { + return true; + } + return false; + }) + } } @App({ diff --git a/ionic/components/searchbar/test/nav/second.html b/ionic/components/searchbar/test/nav/second.html index bd85326841..f95538c7e9 100644 --- a/ionic/components/searchbar/test/nav/second.html +++ b/ionic/components/searchbar/test/nav/second.html @@ -8,6 +8,10 @@ - - + + + + {{ item }} + +