This commit is contained in:
Manuel Mtz-Almeida
2017-03-29 16:47:12 +02:00
parent c9851442c6
commit 515de26a8b
4 changed files with 8 additions and 9 deletions

View File

@ -1,4 +1,4 @@
import { Component, ElementRef, EventEmitter, HostBinding, Input, Optional, Output, Renderer, ViewChild, ViewEncapsulation } from '@angular/core';
import { Component, ElementRef, EventEmitter, Input, Optional, Output, Renderer, ViewChild, ViewEncapsulation } from '@angular/core';
import { NgControl } from '@angular/forms';
import { Config } from '../../config/config';
@ -287,6 +287,7 @@ export class Searchbar extends BaseInput<string> {
* Update the Searchbar input value when the input changes
*/
inputChanged(ev: any) {
this.ionInput.emit(ev);
this.value = ev.target.value;
}

View File

@ -1,7 +1,7 @@
<ion-header>
<ion-navbar>
<ion-searchbar color="primary" autofocus (ionInput)="getItems($event)" placeholder="Filter Schedules">
<ion-searchbar color="primary" autofocus (ionChange)="getItems($event.value)" placeholder="Filter Schedules">
</ion-searchbar>
</ion-navbar>
@ -15,9 +15,9 @@
</ion-header>
<ion-content>
<ion-input [(ngModel)]="value"></ion-input>
<form>
<ion-searchbar (ionInput)="getItems($event)"></ion-searchbar>
<ion-searchbar [(ngModel)]="value" (ionChange)="getItems($event.value)" name="search"></ion-searchbar>
</form>
<ion-list>
<button ion-item *ngFor="let item of items" (click)="showDetail(item)" class="e2eSearchbarNavItem">

View File

@ -7,6 +7,7 @@ import { IonicPage, NavController, ModalController } from '../../../../../..';
})
export class SearchPage {
items: string[];
value = '';
constructor(public navCtrl: NavController, public modalCtrl: ModalController) {
this.initializeItems();
@ -58,13 +59,10 @@ export class SearchPage {
];
}
getItems(ev: any) {
getItems(q: string) {
// Reset items back to all of the items
this.initializeItems();
// set q to the value of the searchbar
var q = ev.value;
// if the value is an empty string don't filter the items
if (!q || q.trim() === '') {
return;

View File

@ -6,6 +6,7 @@ import { pointerCoord } from './dom';
export class ScrollView {
ev: ScrollEvent;
isScrolling = false;
onScrollStart: (ev: ScrollEvent) => void;
@ -23,7 +24,6 @@ export class ScrollView {
private _lsn: Function;
private _endTmr: Function;
constructor(
private _plt: Platform,
private _dom: DomController,