mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-21 04:53:58 +08:00
fix(nav): adds public willLoad lifecycle event
* fix(nav): adds public willLoad lifecycle event * test(menu): adds more asserts
This commit is contained in:

committed by
Adam Bradley

parent
504e6e0440
commit
033e1eae17
@ -419,12 +419,15 @@ export class NavControllerBase extends Ion implements NavController {
|
||||
// create ComponentRef and set it to the entering view
|
||||
enteringView.init(componentFactory.create(childInjector, []));
|
||||
enteringView._state = ViewState.INITIALIZED;
|
||||
this._willLoad(enteringView);
|
||||
this._preLoad(enteringView);
|
||||
}
|
||||
|
||||
_viewAttachToDOM(view: ViewController, componentRef: ComponentRef<any>, viewport: ViewContainerRef) {
|
||||
assert(view._state === ViewState.INITIALIZED, 'view state must be INITIALIZED');
|
||||
|
||||
// fire willLoad before change detection runs
|
||||
this._willLoad(view);
|
||||
|
||||
// render the component ref instance to the DOM
|
||||
// ******** DOM WRITE ****************
|
||||
viewport.insert(componentRef.hostView, viewport.length);
|
||||
@ -438,14 +441,11 @@ export class NavControllerBase extends Ion implements NavController {
|
||||
this._renderer.setElementClass(pageElement, view._cssClass, true);
|
||||
}
|
||||
|
||||
// TODO:
|
||||
// componentRef.changeDetectorRef.detectChanges();
|
||||
componentRef.changeDetectorRef.detectChanges();
|
||||
|
||||
// successfully finished loading the entering view
|
||||
// fire off the "didLoad" lifecycle events
|
||||
this._didLoad(view);
|
||||
|
||||
componentRef.changeDetectorRef.detectChanges();
|
||||
}
|
||||
|
||||
_viewTest(enteringView: ViewController, leavingView: ViewController, ti: TransitionInstruction) {
|
||||
@ -753,6 +753,12 @@ export class NavControllerBase extends Ion implements NavController {
|
||||
}
|
||||
}
|
||||
|
||||
_preLoad(view: ViewController) {
|
||||
assert(this.isTransitioning(), 'nav controller should be transitioning');
|
||||
|
||||
view._preLoad();
|
||||
}
|
||||
|
||||
_willLoad(view: ViewController) {
|
||||
assert(this.isTransitioning(), 'nav controller should be transitioning');
|
||||
|
||||
|
Reference in New Issue
Block a user