import {Component} 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}}
`,
directives: [MyCmpTest]
})
class FirstPage {
constructor(
nav: NavController,
app: IonicApp,
config: Config
) {
this.nav = nav;
this.title = 'First Page';
this.pushPage = FullPage;
this.pages = [];
for (var i = 1; i <= 50; i++) {
this.pages.push(i);
}
}
setPages() {
let items = [
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);
}
reload() {
window.location.reload();
}
}
@Page({
template: `
Full page
This page does not have a nav bar!
`
})
class FullPage {
constructor(
nav: NavController,
params: NavParams
) {
this.nav = nav;
this.params = params;
}
setPages() {
let items = [
FirstPage,
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(
nav: NavController,
viewCtrl: ViewController
) {
this.nav = nav;
this.viewCtrl = viewCtrl;
}
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
Back button hidden w/ ion-navbar hideBackButton
`
})
class AnotherPage {
constructor(
nav: NavController,
viewCtrl: ViewController
) {
this.nav = nav;
this.viewCtrl = viewCtrl;
this.bbHideToggleVal = false;
this._bbCount = 0;
}
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 {
constructor() {
this.root = FirstPage;
}
get isChangeDetecting() {
console.log('isChangeDetecting');
return true;
}
}