test(nav): create nav memory test

This commit is contained in:
Adam Bradley
2016-02-21 21:30:10 -06:00
parent f00abb7ad7
commit ed85ab9863

View File

@ -0,0 +1,86 @@
import {App, Page, NavController} from '../../../../../ionic/ionic';
let delay = 100;
let animate = false;
let count = 0;
@Page({
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;
constructor(private nav: NavController) {}
play() {
this.tmr = setTimeout(() => {
count++;
console.log('push', count);
this.nav.push(Page2, null, {
animate: animate
});
}, delay);
}
onPageDidEnter() {
this.play();
}
stop() {
clearTimeout(this.tmr);
}
}
@Page({
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;
constructor(private nav: NavController) {}
play() {
this.tmr = setTimeout(() => {
count++;
console.log('pop', count);
this.nav.pop({
animate: animate
});
}, delay);
}
onPageDidEnter() {
this.play();
}
stop() {
clearTimeout(this.tmr);
}
}
@App({
template: `<ion-nav [root]="root"></ion-nav>`
})
class E2EApp {
root;
constructor() {
this.root = Page1;
}
}