From 33ac1cc13bcee81b8bcd6110296447fc4ff7d2ce Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Mon, 12 Oct 2015 14:56:40 -0500 Subject: [PATCH] SearchBar --- .../components/search-bar/test/model/index.ts | 43 +++++++++++++++++++ .../search-bar/test/model/main.html | 16 +++++++ 2 files changed, 59 insertions(+) create mode 100644 ionic/components/search-bar/test/model/index.ts create mode 100644 ionic/components/search-bar/test/model/main.html diff --git a/ionic/components/search-bar/test/model/index.ts b/ionic/components/search-bar/test/model/index.ts new file mode 100644 index 0000000000..77b2361ad6 --- /dev/null +++ b/ionic/components/search-bar/test/model/index.ts @@ -0,0 +1,43 @@ +import {NgControl, FORM_DIRECTIVES, FormBuilder, Validators, Control, ControlGroup} from 'angular2/angular2'; + +import {App} from 'ionic/ionic'; +import {SearchPipe} from 'ionic/components/search-bar/search-bar'; + + +function randomTitle() { + var items = ['Soylent', 'Pizza', 'Pumpkin', 'Apple', 'Bologna', 'Turkey', 'Kabob', 'Salad', 'Fruit bowl', 'Fish Tacos', 'Chimichongas', 'Meatloaf']; + return items[Math.floor(Math.random() * items.length)]; +} + +@App({ + templateUrl: 'main.html', + bindings: [NgControl], + directives: [FORM_DIRECTIVES] +}) +class IonicApp { + constructor() { + var fb = new FormBuilder(); + + this.searchQuery = ''; + + this.items = [] + for(let i = 0; i < 100; i++) { + this.items.push({ + title: randomTitle() + }) + } + } + + getItems() { + var q = this.searchQuery; + if(q.trim() == '') { + return this.items; + } + return this.items.filter((v) => { + if(v.title.toLowerCase().indexOf(q.toLowerCase()) >= 0) { + return true; + } + return false; + }) + } +} diff --git a/ionic/components/search-bar/test/model/main.html b/ionic/components/search-bar/test/model/main.html new file mode 100644 index 0000000000..dd76b512a2 --- /dev/null +++ b/ionic/components/search-bar/test/model/main.html @@ -0,0 +1,16 @@ + + + + +
+ + + + + {{item.title}} + + +
+
+ +