Experimenting with lifecycle events

This commit is contained in:
Max Lynch
2015-06-01 17:18:02 -05:00
parent 6af06138ac
commit b7747d1620
3 changed files with 21 additions and 1 deletions

View File

@ -3,6 +3,7 @@ import {bind} from 'angular2/di';
import * as util from 'ionic/util';
import {NavController} from './nav-controller';
import {Lifecycle} from 'ionic/components/view/lifecycle';
export class NavItem {
@ -48,7 +49,10 @@ export class NavItem {
]);
this.nav.loader.loadNextToExistingLocation(this.Component, this.nav.contentElementRef, injector).then((componentRef) => {
console.log('nav-item loadNextToExistingLocation', this.nav.contentElementRef)
Lifecycle.viewLoaded(componentRef.instance);
console.log('nav-item loadNextToExistingLocation', this.nav.contentElementRef);
let navbarContainer = this.nav.navbarContainerRef;
if (componentRef && componentRef.dispose && navbarContainer) {

View File

@ -34,6 +34,14 @@ export class FirstPage {
this.val = Math.round(Math.random() * 8999) + 1000;
}
viewLoaded() {
console.log('VIEW LOADED');
}
viewWillShow() {
console.log('VIEW WILL SHOW');
}
push() {
this.nav.push(SecondPage, { id: 8675309, myData: [1,2,3,4] }, { animation: 'ios' });
}

View File

@ -0,0 +1,8 @@
export class Lifecycle {
static viewLoaded(component) {
component.viewLoaded && component.viewLoaded();
}
static viewWillShow(component) {
component.viewWillShow && component.viewWillShow();
}
}