test(infiniteScroll): build ViewChild example

This commit is contained in:
Adam Bradley
2016-04-17 00:18:24 -05:00
parent b282e90e2c
commit 79dd0df90b
2 changed files with 21 additions and 1 deletions

View File

@ -1,3 +1,4 @@
import {ViewChild} from 'angular2/core';
import {App, Page, InfiniteScroll, NavController} from 'ionic-angular';
@ -5,7 +6,12 @@ import {App, Page, InfiniteScroll, NavController} from 'ionic-angular';
templateUrl: 'main.html'
})
class E2EPage1 {
@ViewChild(InfiniteScroll) set _infiniteScroll(val) {
console.log('ViewChild')
this.infiniteScroll = val
}
items = [];
enabled: boolean = true;
constructor(private nav: NavController) {
for (var i = 0; i < 30; i++) {
@ -25,7 +31,8 @@ class E2EPage1 {
infiniteScroll.complete();
if (this.items.length > 90) {
infiniteScroll.enable(false);
this.enabled = false;
infiniteScroll.enable(this.enabled);
}
});
}
@ -33,6 +40,11 @@ class E2EPage1 {
goToPage2() {
this.nav.push(E2EPage2);
}
toggleInfiniteScroll() {
this.enabled = !this.enabled;
this.infiniteScroll.enable(this.enabled);
}
}

View File

@ -2,6 +2,14 @@
<ion-content>
<p>
InfiniteScroll is enabled: {{enabled}}
</p>
<button (click)="toggleInfiniteScroll()" block>
Toggle InfiniteScroll Enabled
</button>
<ion-list>
<button ion-item (click)="goToPage2()" *ngFor="#item of items">
{{ item }}