mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
Query
This commit is contained in:
@@ -12,13 +12,12 @@ import {IonicComponent} from 'ionic/config/component'
|
||||
cancelText: 'cancel-text',
|
||||
placeholderText: 'placeholder-text',
|
||||
list: 'list',
|
||||
query: 'query',
|
||||
value: 'value'
|
||||
query: 'query'
|
||||
}
|
||||
})
|
||||
@View({
|
||||
template: `<div class="search-bar-input-container">
|
||||
<input [value]="value" (input)="inputChanged($event)" class="search-bar-input" type="search" [attr.placeholder]="placeholderText">
|
||||
<input (input)="inputChanged($event)" class="search-bar-input" type="search" [attr.placeholder]="placeholderText">
|
||||
</div>
|
||||
<button class="button search-bar-cancel">{{ cancelText }}</button>`
|
||||
})
|
||||
|
||||
@@ -33,7 +33,7 @@ class IonicApp {
|
||||
});
|
||||
|
||||
|
||||
this.query = '';
|
||||
this.query = 'HELLO';
|
||||
|
||||
this.items = []
|
||||
for(let i = 0; i < 100; i++) {
|
||||
@@ -42,6 +42,18 @@ class IonicApp {
|
||||
})
|
||||
}
|
||||
}
|
||||
getItems() {
|
||||
var q = this.form.controls.searchQuery.value;
|
||||
if(q.trim() == '') {
|
||||
return this.items;
|
||||
}
|
||||
return this.items.filter((v) => {
|
||||
if(v.title.toLowerCase().indexOf(q.toLowerCase()) >= 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
import { defaultPipes } from 'angular2/change_detection';
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
<ion-list #list>
|
||||
|
||||
<ion-item *for="#item of items | search:form.controls.searchControl.value">
|
||||
<ion-item *for="#item of getItems()"><!--items | search:form.controls.searchControl.value">-->
|
||||
{{item.title}}
|
||||
</ion-item>
|
||||
</ion-list>
|
||||
|
||||
Reference in New Issue
Block a user