Updating search-bar basic demo to show the detectchanges from angular firing 1000's of times

This commit is contained in:
jbavari
2015-10-13 11:56:53 -06:00
parent 0ca3ec6555
commit bb49c9f114
3 changed files with 12 additions and 8 deletions

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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> -->