mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
Updating search-bar basic demo to show the detectchanges from angular firing 1000's of times
This commit is contained in:
@ -92,6 +92,7 @@ export class SearchBar extends Ion {
|
||||
}
|
||||
|
||||
inputChanged(event) {
|
||||
console.log('input changed');
|
||||
this.writeValue(event.target.value);
|
||||
this.onChange(event.target.value);
|
||||
}
|
||||
|
@ -17,9 +17,7 @@ function randomTitle() {
|
||||
class IonicApp {
|
||||
constructor() {
|
||||
var fb = new FormBuilder();
|
||||
this.form = fb.group({
|
||||
searchQuery: ['', Validators.required]
|
||||
});
|
||||
this.searchQuery = '';
|
||||
|
||||
this.items = []
|
||||
for(let i = 0; i < 100; i++) {
|
||||
@ -29,8 +27,13 @@ class IonicApp {
|
||||
}
|
||||
}
|
||||
|
||||
doThis() {
|
||||
console.log('Doing this');
|
||||
}
|
||||
|
||||
getItems() {
|
||||
var q = this.form.controls.searchQuery.value;
|
||||
var q = this.searchQuery;
|
||||
console.log('Its changing');
|
||||
if(q.trim() == '') {
|
||||
return this.items;
|
||||
}
|
||||
|
@ -2,15 +2,15 @@
|
||||
<!-- <ion-view nav-title="Search Bar"> -->
|
||||
|
||||
<ion-content>
|
||||
<form [ng-form-model]="form">
|
||||
<!-- <form [ng-form-model]="form"> -->
|
||||
|
||||
<ion-search-bar ng-control="searchQuery"></ion-search-bar>
|
||||
<ion-search-bar [(ng-model)]="searchQuery"></ion-search-bar>
|
||||
<ion-list inset #list>
|
||||
<ion-item *ng-for="#item of getItems()">
|
||||
<ion-item-sliding *ng-for="#item of getItems()" (click)="doThis">
|
||||
{{item.title}}
|
||||
</ion-item>
|
||||
</ion-list>
|
||||
</form>
|
||||
<!-- </form> -->
|
||||
</ion-content>
|
||||
|
||||
<!-- </ion-view> -->
|
||||
|
Reference in New Issue
Block a user