mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
fix(navCtrl): use lower level compiler API
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
import {Compiler, ElementRef, Injector, provide, NgZone, DynamicComponentLoader, AppViewManager, Renderer} from 'angular2/angular2';
|
import {Compiler, ElementRef, Injector, provide, NgZone, AppViewManager, Renderer} from 'angular2/angular2';
|
||||||
import {wtfLeave, wtfCreateScope} from 'angular2/angular2';
|
import {wtfLeave, wtfCreateScope} from 'angular2/angular2';
|
||||||
|
|
||||||
import {Ion} from '../ion';
|
import {Ion} from '../ion';
|
||||||
@ -107,7 +107,6 @@ export class NavController extends Ion {
|
|||||||
keyboard: Keyboard,
|
keyboard: Keyboard,
|
||||||
elementRef: ElementRef,
|
elementRef: ElementRef,
|
||||||
compiler: Compiler,
|
compiler: Compiler,
|
||||||
loader: DynamicComponentLoader,
|
|
||||||
viewManager: AppViewManager,
|
viewManager: AppViewManager,
|
||||||
zone: NgZone,
|
zone: NgZone,
|
||||||
renderer: Renderer
|
renderer: Renderer
|
||||||
@ -120,7 +119,6 @@ export class NavController extends Ion {
|
|||||||
this.keyboard = keyboard;
|
this.keyboard = keyboard;
|
||||||
|
|
||||||
this._compiler = compiler;
|
this._compiler = compiler;
|
||||||
this._loader = loader;
|
|
||||||
this._viewManager = viewManager;
|
this._viewManager = viewManager;
|
||||||
this._zone = zone;
|
this._zone = zone;
|
||||||
this._renderer = renderer;
|
this._renderer = renderer;
|
||||||
@ -793,23 +791,34 @@ export class NavController extends Ion {
|
|||||||
loadPage(viewCtrl, navbarContainerRef, opts, done) {
|
loadPage(viewCtrl, navbarContainerRef, opts, done) {
|
||||||
let wtfScope = wtfCreateScope('NavController#loadPage()')();
|
let wtfScope = wtfCreateScope('NavController#loadPage()')();
|
||||||
|
|
||||||
let providers = this.providers.concat(Injector.resolve([
|
// guts of DynamicComponentLoader#loadIntoLocation
|
||||||
provide(ViewController, {useValue: viewCtrl}),
|
this._compiler.compileInHost(viewCtrl.componentType).then(hostProtoViewRef => {
|
||||||
provide(NavParams, {useValue: viewCtrl.params})
|
let providers = this.providers.concat(Injector.resolve([
|
||||||
]));
|
provide(ViewController, {useValue: viewCtrl}),
|
||||||
|
provide(NavParams, {useValue: viewCtrl.params})
|
||||||
|
]));
|
||||||
|
|
||||||
this._loader.loadIntoLocation(viewCtrl.componentType, this.elementRef, 'contents', providers).then(componentRef => {
|
let location = this._viewManager.getNamedElementInComponentView(this.elementRef, 'contents');
|
||||||
|
|
||||||
|
let viewContainer = this._viewManager.getViewContainer(location);
|
||||||
|
let hostViewRef =
|
||||||
|
viewContainer.createHostView(hostProtoViewRef, viewContainer.length, providers);
|
||||||
|
let newLocation = this._viewManager.getHostElement(hostViewRef);
|
||||||
|
let component = this._viewManager.getComponent(newLocation);
|
||||||
|
|
||||||
viewCtrl.addDestroy(() => {
|
viewCtrl.addDestroy(() => {
|
||||||
componentRef.dispose();
|
let index = viewContainer.indexOf(hostViewRef);
|
||||||
|
if (index !== -1) {
|
||||||
|
viewContainer.remove(index);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// a new ComponentRef has been created
|
// a new ComponentRef has been created
|
||||||
// set the ComponentRef's instance to this ViewController
|
// set the ComponentRef's instance to this ViewController
|
||||||
viewCtrl.setInstance(componentRef.instance);
|
viewCtrl.setInstance(component);
|
||||||
|
|
||||||
// remember the ElementRef to the ion-page elementRef that was just created
|
// remember the ElementRef to the ion-page elementRef that was just created
|
||||||
viewCtrl.setPageRef(componentRef.location);
|
viewCtrl.setPageRef(newLocation);
|
||||||
|
|
||||||
if (!navbarContainerRef) {
|
if (!navbarContainerRef) {
|
||||||
navbarContainerRef = viewCtrl.getNavbarViewRef();
|
navbarContainerRef = viewCtrl.getNavbarViewRef();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {Component, Directive, ElementRef, Host, Optional, forwardRef, Inject, NgZone, Compiler, AppViewManager, DynamicComponentLoader, Renderer, ViewContainerRef} from 'angular2/angular2';
|
import {Component, Directive, ElementRef, Host, Optional, forwardRef, Inject, NgZone, Compiler, AppViewManager, Renderer, ViewContainerRef} from 'angular2/angular2';
|
||||||
|
|
||||||
import {IonicApp} from '../app/app';
|
import {IonicApp} from '../app/app';
|
||||||
import {Config} from '../../config/config';
|
import {Config} from '../../config/config';
|
||||||
@ -117,13 +117,11 @@ export class Nav extends NavController {
|
|||||||
keyboard: Keyboard,
|
keyboard: Keyboard,
|
||||||
elementRef: ElementRef,
|
elementRef: ElementRef,
|
||||||
compiler: Compiler,
|
compiler: Compiler,
|
||||||
loader: DynamicComponentLoader,
|
|
||||||
viewManager: AppViewManager,
|
viewManager: AppViewManager,
|
||||||
zone: NgZone,
|
zone: NgZone,
|
||||||
renderer: Renderer
|
renderer: Renderer
|
||||||
) {
|
) {
|
||||||
super(hostNavCtrl, app, config, keyboard, elementRef, compiler,
|
super(hostNavCtrl, app, config, keyboard, elementRef, compiler, viewManager, zone, renderer);
|
||||||
loader, viewManager, zone, renderer);
|
|
||||||
|
|
||||||
if (viewCtrl) {
|
if (viewCtrl) {
|
||||||
// an ion-nav can also act as an ion-page within a parent ion-nav
|
// an ion-nav can also act as an ion-page within a parent ion-nav
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {Component, ElementRef, Compiler, DynamicComponentLoader, AppViewManager, NgZone, Renderer} from 'angular2/angular2';
|
import {Component, ElementRef, Compiler, AppViewManager, NgZone, Renderer} from 'angular2/angular2';
|
||||||
|
|
||||||
import {IonicApp} from '../app/app';
|
import {IonicApp} from '../app/app';
|
||||||
import {Config} from '../../config/config';
|
import {Config} from '../../config/config';
|
||||||
@ -20,13 +20,11 @@ export class OverlayNav extends NavController {
|
|||||||
keyboard: Keyboard,
|
keyboard: Keyboard,
|
||||||
elementRef: ElementRef,
|
elementRef: ElementRef,
|
||||||
compiler: Compiler,
|
compiler: Compiler,
|
||||||
loader: DynamicComponentLoader,
|
|
||||||
viewManager: AppViewManager,
|
viewManager: AppViewManager,
|
||||||
zone: NgZone,
|
zone: NgZone,
|
||||||
renderer: Renderer
|
renderer: Renderer
|
||||||
) {
|
) {
|
||||||
super(null, app, config, keyboard, elementRef, compiler,
|
super(null, app, config, keyboard, elementRef, compiler, viewManager, zone, renderer);
|
||||||
loader, viewManager, zone, renderer);
|
|
||||||
|
|
||||||
if (overlayCtrl.anchor) {
|
if (overlayCtrl.anchor) {
|
||||||
throw ('An app should only have one <ion-overlay></ion-overlay>');
|
throw ('An app should only have one <ion-overlay></ion-overlay>');
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {Component, Directive, Host, ElementRef, Compiler, DynamicComponentLoader, AppViewManager, NgZone, Renderer} from 'angular2/angular2';
|
import {Component, Directive, Host, ElementRef, Compiler, AppViewManager, NgZone, Renderer} from 'angular2/angular2';
|
||||||
|
|
||||||
import {IonicApp} from '../app/app';
|
import {IonicApp} from '../app/app';
|
||||||
import {Config} from '../../config/config';
|
import {Config} from '../../config/config';
|
||||||
@ -76,14 +76,12 @@ export class Tab extends NavController {
|
|||||||
keyboard: Keyboard,
|
keyboard: Keyboard,
|
||||||
elementRef: ElementRef,
|
elementRef: ElementRef,
|
||||||
compiler: Compiler,
|
compiler: Compiler,
|
||||||
loader: DynamicComponentLoader,
|
|
||||||
viewManager: AppViewManager,
|
viewManager: AppViewManager,
|
||||||
zone: NgZone,
|
zone: NgZone,
|
||||||
renderer: Renderer
|
renderer: Renderer
|
||||||
) {
|
) {
|
||||||
// A Tab is a NavController for its child pages
|
// A Tab is a NavController for its child pages
|
||||||
super(parentTabs, app, config, keyboard, elementRef, compiler,
|
super(parentTabs, app, config, keyboard, elementRef, compiler, viewManager, zone, renderer);
|
||||||
loader, viewManager, zone, renderer);
|
|
||||||
|
|
||||||
this._isInitial = parentTabs.add(this);
|
this._isInitial = parentTabs.add(this);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user