Routing with lifecycles

This commit is contained in:
Max Lynch
2015-06-17 20:31:34 -05:00
parent d4d3728a34
commit dd16e1d0c5
4 changed files with 21 additions and 16 deletions

View File

@@ -1,12 +1,13 @@
import {Component, Directive} from 'angular2/src/core/annotations_impl/annotations';
import {Component, Directive, onInit} from 'angular2/src/core/annotations_impl/annotations';
import {View} from 'angular2/src/core/annotations_impl/view';
import {ObservableWrapper} from 'angular2/src/facade/async';
import {Routable, Router, NavController, NavbarTemplate, Navbar, NavPush, Content} from 'ionic/ionic';
import {SecondPage} from './second-page';
@Component({selector: 'ion-view'})
@Component({
selector: 'ion-view',
lifecycle: [onInit]
})
@View({
template: '' +
'<ion-navbar *navbar>' +
@@ -36,22 +37,18 @@ export class FirstPage {
this.nav = nav;
this.val = Math.round(Math.random() * 8999) + 1000;
this.router = FirstPage.router.invoke(this);
this.pushPage = SecondPage;
this.pushData = {
id: 420
}
}
setTimeout(() => {
console.log(this._viewDidEnter);
ObservableWrapper.subscribe(this._viewDidEnter, () => {
console.log('ENTERRRRR');
});
});
onInit() {
}
viewLoaded() {
this.router = FirstPage.router.invoke(this);
console.log('viewLoaded first page');
}
@@ -61,7 +58,6 @@ export class FirstPage {
viewDidEnter() {
console.log('viewDidEnter first page');
Router.emit(this.router.routeInfo.url);
}
viewWillLeave() {

View File

@@ -36,7 +36,6 @@ export class SecondPage {
this.params = params;
this.val = Math.round(Math.random() * 8999) + 1000;
this.router = SecondPage.router.invoke(this);
console.log('Second page params:', params);
}
@@ -51,6 +50,7 @@ export class SecondPage {
viewLoaded() {
console.log('viewLoaded second page');
this.router = SecondPage.router.invoke(this);
}
viewWillEnter() {
@@ -59,7 +59,6 @@ export class SecondPage {
viewDidEnter() {
console.log('viewDidEnter second page');
Router.emit(this.router.routeInfo.url);
}
viewWillLeave() {