mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-23 05:58:26 +08:00
test(infiniteScroll): build ViewChild example
This commit is contained in:
@ -1,3 +1,4 @@
|
|||||||
|
import {ViewChild} from 'angular2/core';
|
||||||
import {App, Page, InfiniteScroll, NavController} from 'ionic-angular';
|
import {App, Page, InfiniteScroll, NavController} from 'ionic-angular';
|
||||||
|
|
||||||
|
|
||||||
@ -5,7 +6,12 @@ import {App, Page, InfiniteScroll, NavController} from 'ionic-angular';
|
|||||||
templateUrl: 'main.html'
|
templateUrl: 'main.html'
|
||||||
})
|
})
|
||||||
class E2EPage1 {
|
class E2EPage1 {
|
||||||
|
@ViewChild(InfiniteScroll) set _infiniteScroll(val) {
|
||||||
|
console.log('ViewChild')
|
||||||
|
this.infiniteScroll = val
|
||||||
|
}
|
||||||
items = [];
|
items = [];
|
||||||
|
enabled: boolean = true;
|
||||||
|
|
||||||
constructor(private nav: NavController) {
|
constructor(private nav: NavController) {
|
||||||
for (var i = 0; i < 30; i++) {
|
for (var i = 0; i < 30; i++) {
|
||||||
@ -25,7 +31,8 @@ class E2EPage1 {
|
|||||||
infiniteScroll.complete();
|
infiniteScroll.complete();
|
||||||
|
|
||||||
if (this.items.length > 90) {
|
if (this.items.length > 90) {
|
||||||
infiniteScroll.enable(false);
|
this.enabled = false;
|
||||||
|
infiniteScroll.enable(this.enabled);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -33,6 +40,11 @@ class E2EPage1 {
|
|||||||
goToPage2() {
|
goToPage2() {
|
||||||
this.nav.push(E2EPage2);
|
this.nav.push(E2EPage2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggleInfiniteScroll() {
|
||||||
|
this.enabled = !this.enabled;
|
||||||
|
this.infiniteScroll.enable(this.enabled);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,6 +2,14 @@
|
|||||||
|
|
||||||
<ion-content>
|
<ion-content>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
InfiniteScroll is enabled: {{enabled}}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<button (click)="toggleInfiniteScroll()" block>
|
||||||
|
Toggle InfiniteScroll Enabled
|
||||||
|
</button>
|
||||||
|
|
||||||
<ion-list>
|
<ion-list>
|
||||||
<button ion-item (click)="goToPage2()" *ngFor="#item of items">
|
<button ion-item (click)="goToPage2()" *ngFor="#item of items">
|
||||||
{{ item }}
|
{{ item }}
|
||||||
|
Reference in New Issue
Block a user