mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 21:48:42 +08:00
86 lines
1.3 KiB
TypeScript
86 lines
1.3 KiB
TypeScript
import { Component} from '@angular/core';
|
|
import { ionicBootstrap, NavController } from '../../../../../src';
|
|
|
|
|
|
let delay = 100;
|
|
let animate = false;
|
|
let count = 0;
|
|
|
|
@Component({
|
|
template: `
|
|
<ion-content padding text-center>
|
|
<p>Page 1</p>
|
|
<button (click)="stop()">Stop</button>
|
|
<button (click)="play()">Play</button>
|
|
</ion-content>
|
|
`
|
|
})
|
|
class Page1 {
|
|
tmr: number;
|
|
|
|
constructor(private nav: NavController) {}
|
|
|
|
play() {
|
|
this.tmr = setTimeout(() => {
|
|
count++;
|
|
console.log('push', count);
|
|
|
|
this.nav.push(Page2, null, {
|
|
animate: animate
|
|
});
|
|
}, delay);
|
|
}
|
|
|
|
ionViewDidEnter() {
|
|
this.play();
|
|
}
|
|
|
|
stop() {
|
|
clearTimeout(this.tmr);
|
|
}
|
|
}
|
|
|
|
@Component({
|
|
template: `
|
|
<ion-content padding text-center>
|
|
<p>Page 2</p>
|
|
<button (click)="stop()">Stop</button>
|
|
<button (click)="play()">Play</button>
|
|
</ion-content>
|
|
`
|
|
})
|
|
class Page2 {
|
|
tmr: number;
|
|
|
|
constructor(private nav: NavController) {}
|
|
|
|
play() {
|
|
this.tmr = setTimeout(() => {
|
|
count++;
|
|
console.log('pop', count);
|
|
|
|
this.nav.pop({
|
|
animate: animate
|
|
});
|
|
}, delay);
|
|
}
|
|
|
|
ionViewDidEnter() {
|
|
this.play();
|
|
}
|
|
|
|
stop() {
|
|
clearTimeout(this.tmr);
|
|
}
|
|
}
|
|
|
|
|
|
@Component({
|
|
template: `<ion-nav [root]="root"></ion-nav>`
|
|
})
|
|
class E2EApp {
|
|
root = Page1;
|
|
}
|
|
|
|
ionicBootstrap(E2EApp);
|