mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +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';
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 }}
|
||||
|
Reference in New Issue
Block a user