diff --git a/src/components/searchbar/searchbar.ts b/src/components/searchbar/searchbar.ts index 7d3f420aa5f..44237c589ce 100644 --- a/src/components/searchbar/searchbar.ts +++ b/src/components/searchbar/searchbar.ts @@ -192,14 +192,6 @@ export class Searchbar { this.positionElements(); } - /** - * @private - * After Content is checked position the elements - */ - ngAfterContentChecked() { - this.positionElements(); - } - /** * @private * Positions the input search icon, placeholder, and the cancel button @@ -352,6 +344,7 @@ export class Searchbar { */ writeValue(val: any) { this._value = val; + this.positionElements(); } /** diff --git a/src/components/searchbar/test/nav/detail.html b/src/components/searchbar/test/nav/detail.html new file mode 100644 index 00000000000..ce4b4bed6fd --- /dev/null +++ b/src/components/searchbar/test/nav/detail.html @@ -0,0 +1,7 @@ + + Detail + + + +

City: {{city}}

+
diff --git a/src/components/searchbar/test/nav/e2e.ts b/src/components/searchbar/test/nav/e2e.ts index 07fecbd745f..d0952fe13f5 100644 --- a/src/components/searchbar/test/nav/e2e.ts +++ b/src/components/searchbar/test/nav/e2e.ts @@ -1,4 +1,4 @@ -it('should navigate to searchbar', function() { - element(by.css('.e2eSearchbarNav')).click(); +it('should navigate to details', function() { + element(by.css('.e2eSearchbarNavItem')).click(); }); diff --git a/src/components/searchbar/test/nav/index.ts b/src/components/searchbar/test/nav/index.ts index de9c5f45370..cfdaff25c2d 100644 --- a/src/components/searchbar/test/nav/index.ts +++ b/src/components/searchbar/test/nav/index.ts @@ -1,31 +1,32 @@ -import {Component} from '@angular/core'; -import {ionicBootstrap, NavController} from '../../../../../src'; +import { Component } from '@angular/core'; +import { ionicBootstrap, NavController, NavParams } from '../../../../../src'; @Component({ - templateUrl: 'first.html' + templateUrl: 'main.html' }) -class FirstPage { - constructor(private _nav: NavController) { - - } +class MainPage { + constructor(private _nav: NavController) { } goToSecond() { - this._nav.push(SecondPage); + this._nav.push(SearchPage); } } @Component({ - templateUrl: 'second.html' + templateUrl: 'search.html' }) -class SecondPage { - searchQuery = ''; +class SearchPage { items: string[]; - constructor() { + constructor(private _nav: NavController) { this.initializeItems(); } + showDetail(item: any) { + this._nav.push(DetailPage, {city: item}); + } + initializeItems() { this.items = [ 'Amsterdam', @@ -68,15 +69,15 @@ class SecondPage { ]; } - getItems(searchbar) { + getItems(ev: any) { // Reset items back to all of the items this.initializeItems(); // set q to the value of the searchbar - var q = searchbar.value; + var q = ev.target.value; // if the value is an empty string don't filter the items - if (q.trim() == '') { + if (!q || q.trim() === '') { return; } @@ -89,11 +90,30 @@ class SecondPage { } } +@Component({ + templateUrl: 'detail.html' +}) +class DetailPage { + city: string; + + constructor(private _navParams: NavParams) { + this.city = _navParams.get('city'); + } +} + +@Component({ + templateUrl: 'tabs.html' +}) +class TabsPage { + mainPage = MainPage; + searchPage = SearchPage; +} + @Component({ template: '' }) class E2EApp { - root = FirstPage; + root = TabsPage; } ionicBootstrap(E2EApp); diff --git a/src/components/searchbar/test/nav/first.html b/src/components/searchbar/test/nav/main.html similarity index 53% rename from src/components/searchbar/test/nav/first.html rename to src/components/searchbar/test/nav/main.html index fe0c7f79489..a44f3c3861d 100644 --- a/src/components/searchbar/test/nav/first.html +++ b/src/components/searchbar/test/nav/main.html @@ -3,5 +3,5 @@ - + diff --git a/src/components/searchbar/test/nav/search.html b/src/components/searchbar/test/nav/search.html new file mode 100644 index 00000000000..28290065d39 --- /dev/null +++ b/src/components/searchbar/test/nav/search.html @@ -0,0 +1,17 @@ + + Searchbar + + + + + + + + + + + + + diff --git a/src/components/searchbar/test/nav/second.html b/src/components/searchbar/test/nav/second.html deleted file mode 100644 index 27a0fc938a7..00000000000 --- a/src/components/searchbar/test/nav/second.html +++ /dev/null @@ -1,17 +0,0 @@ - - Searchbar - - - - - - - - - - - - {{ item }} - - - diff --git a/src/components/searchbar/test/nav/tabs.html b/src/components/searchbar/test/nav/tabs.html new file mode 100644 index 00000000000..56025517d48 --- /dev/null +++ b/src/components/searchbar/test/nav/tabs.html @@ -0,0 +1,4 @@ + + + +