mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
Experimenting with lifecycle events
This commit is contained in:
@ -3,6 +3,7 @@ import {bind} from 'angular2/di';
|
|||||||
|
|
||||||
import * as util from 'ionic/util';
|
import * as util from 'ionic/util';
|
||||||
import {NavController} from './nav-controller';
|
import {NavController} from './nav-controller';
|
||||||
|
import {Lifecycle} from 'ionic/components/view/lifecycle';
|
||||||
|
|
||||||
|
|
||||||
export class NavItem {
|
export class NavItem {
|
||||||
@ -48,7 +49,10 @@ export class NavItem {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
this.nav.loader.loadNextToExistingLocation(this.Component, this.nav.contentElementRef, injector).then((componentRef) => {
|
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;
|
let navbarContainer = this.nav.navbarContainerRef;
|
||||||
|
|
||||||
if (componentRef && componentRef.dispose && navbarContainer) {
|
if (componentRef && componentRef.dispose && navbarContainer) {
|
||||||
|
@ -34,6 +34,14 @@ export class FirstPage {
|
|||||||
this.val = Math.round(Math.random() * 8999) + 1000;
|
this.val = Math.round(Math.random() * 8999) + 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
viewLoaded() {
|
||||||
|
console.log('VIEW LOADED');
|
||||||
|
}
|
||||||
|
|
||||||
|
viewWillShow() {
|
||||||
|
console.log('VIEW WILL SHOW');
|
||||||
|
}
|
||||||
|
|
||||||
push() {
|
push() {
|
||||||
this.nav.push(SecondPage, { id: 8675309, myData: [1,2,3,4] }, { animation: 'ios' });
|
this.nav.push(SecondPage, { id: 8675309, myData: [1,2,3,4] }, { animation: 'ios' });
|
||||||
}
|
}
|
||||||
|
8
ionic/components/view/lifecycle.js
Normal file
8
ionic/components/view/lifecycle.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
export class Lifecycle {
|
||||||
|
static viewLoaded(component) {
|
||||||
|
component.viewLoaded && component.viewLoaded();
|
||||||
|
}
|
||||||
|
static viewWillShow(component) {
|
||||||
|
component.viewWillShow && component.viewWillShow();
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user