mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
test(nav): nav.insert test
This commit is contained in:
70
ionic/components/nav/test/insert-views/index.ts
Normal file
70
ionic/components/nav/test/insert-views/index.ts
Normal file
@ -0,0 +1,70 @@
|
||||
import {App, Page, NavController} from 'ionic/ionic';
|
||||
|
||||
|
||||
|
||||
@Page({
|
||||
template: `
|
||||
<ion-navbar *navbar>
|
||||
<ion-title>Root</ion-title>
|
||||
</ion-navbar>
|
||||
|
||||
<ion-content padding>
|
||||
<button block (click)="pushPage()">Push Page</block>
|
||||
</ion-content>`,
|
||||
})
|
||||
class FirstPage {
|
||||
constructor(nav: NavController) {
|
||||
this.nav = nav;
|
||||
}
|
||||
pushPage(){
|
||||
this.nav.push(SecondPage)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Page({
|
||||
template: `
|
||||
<ion-navbar *navbar>
|
||||
<ion-title>Root</ion-title>
|
||||
</ion-navbar>
|
||||
|
||||
<ion-content padding>
|
||||
<h1>Second page</h1>
|
||||
<button block (click)="insertPage()">Insert Page</block>
|
||||
</ion-content>
|
||||
`
|
||||
})
|
||||
class SecondPage {
|
||||
constructor(nav: NavController) {
|
||||
this.nav = nav;
|
||||
}
|
||||
insertPage(){
|
||||
this.nav.insert(InsertPage, 1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Page({
|
||||
template: `
|
||||
<ion-navbar *navbar>
|
||||
<ion-title>Inserted Paged</ion-title>
|
||||
</ion-navbar>
|
||||
<ion-content padding>
|
||||
Inserted Page
|
||||
</ion-content>
|
||||
`
|
||||
})
|
||||
class InsertPage {
|
||||
constructor() {}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@App({
|
||||
template: `<ion-nav [root]="root"></ion-nav>`
|
||||
})
|
||||
class E2EApp {
|
||||
constructor() {
|
||||
this.root = FirstPage;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user