import {Component, Type} from 'angular2/core';
import {App, NavController} from 'ionic/ionic';
import {Page, Config, IonicApp} from 'ionic/ionic';
import {NavParams, NavController, ViewController, IONIC_DIRECTIVES} from 'ionic/ionic';
@Component({
selector: 'my-cmp',
template: `
My Custom Component Test
`,
directives: [IONIC_DIRECTIVES]
})
class MyCmpTest{}
@Page({
template: `
{{title}}
{{title}}
Text Input
`,
directives: [MyCmpTest]
})
class FirstPage {
pushPage;
title = 'First Page';
pages: Array = [];
constructor(
private nav: NavController,
app: IonicApp,
config: Config
) {
this.pushPage = FullPage;
for (var i = 1; i <= 50; i++) {
this.pages.push(i);
}
}
setPages() {
let items = [
{page: PrimaryHeaderPage}
];
this.nav.setPages(items);
}
setRoot() {
this.nav.setRoot(PrimaryHeaderPage);
}
pushPrimaryHeaderPage() {
this.nav.push(PrimaryHeaderPage);
}
pushFullPage() {
this.nav.push(FullPage, { id: 8675309, myData: [1,2,3,4] } );
}
pushAnother() {
this.nav.push(AnotherPage);
}
quickPush() {
this.nav.push(AnotherPage);
setTimeout(() => {
this.nav.push(PrimaryHeaderPage);
}, 150);
}
quickPop() {
this.nav.push(AnotherPage);
setTimeout(() => {
this.nav.remove(1, 1);
}, 250);
}
reload() {
window.location.reload();
}
}
@Page({
template: `
Full page
This page does not have a nav bar!
`
})
class FullPage {
constructor(
private nav: NavController,
private params: NavParams
) {}
setPages() {
let items = [
{page: FirstPage},
{page: PrimaryHeaderPage}
];
this.nav.setPages(items);
}
pushPrimaryHeaderPage() {
this.nav.push(PrimaryHeaderPage);
}
pushAnother() {
this.nav.push(AnotherPage);
}
pushFirstPage() {
this.nav.push(FirstPage);
}
}
@Page({
template: `
Primary Color Page Header
`
})
class PrimaryHeaderPage {
constructor(
private nav: NavController,
private viewCtrl: ViewController
) {}
onPageWillEnter() {
this.viewCtrl.setBackButtonText('Previous');
}
pushAnother() {
this.nav.push(AnotherPage);
}
pushFullPage() {
this.nav.push(FullPage, { id: 8675309, myData: [1,2,3,4] } );
}
insert() {
this.nav.insert(2, FirstPage);
}
removeSecond() {
this.nav.remove(1);
}
setRoot() {
this.nav.setRoot(AnotherPage);
}
}
@Page({
template: `
Another Page Header
Text Input
Back button hidden w/ ion-navbar hideBackButton
`
})
class AnotherPage {
bbHideToggleVal = false;
bbCount = 0;
constructor(
private nav: NavController,
private viewCtrl: ViewController
) {}
pushFullPage() {
this.nav.push(FullPage);
}
pushPrimaryHeaderPage() {
this.nav.push(PrimaryHeaderPage);
}
pushFirstPage() {
this.nav.push(FirstPage);
}
setRoot() {
this.nav.setRoot(FirstPage);
}
toggleBackButton() {
this.bbHideToggleVal = !this.bbHideToggleVal
this.viewCtrl.showBackButton(this.bbHideToggleVal);
}
setBackButtonText() {
let backButtonText = 'Messages';
if (this.bbCount > 0) {
backButtonText += ` (${this.bbCount})`;
}
this.viewCtrl.setBackButtonText(backButtonText);
++this.bbCount;
}
}
@App({
pages: [FirstPage, FullPage, PrimaryHeaderPage, AnotherPage],
template: ``,
host: {
'[class.is-change-detecting]': 'isChangeDetecting'
}
})
class E2EApp {
root;
constructor() {
this.root = FirstPage;
}
get isChangeDetecting() {
console.log('isChangeDetecting');
return true;
}
}