mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix back button
This commit is contained in:
@@ -32,9 +32,11 @@ export class BackButton {
|
||||
}
|
||||
|
||||
onClick(ev) {
|
||||
this.navItem.nav.pop();
|
||||
ev.stopPropagation();
|
||||
ev.preventDefault();
|
||||
|
||||
let navItem = this.navItem;
|
||||
navItem && navItem.nav && navItem.nav.pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import {NavBase} from './nav-base';
|
||||
export class NavItem {
|
||||
|
||||
constructor(navBase, ComponentClass, params = {}) {
|
||||
this.navBase = navBase;
|
||||
this.nav = navBase;
|
||||
this.ComponentClass = ComponentClass;
|
||||
this.params = params;
|
||||
this.instance = null;
|
||||
@@ -32,7 +32,7 @@ export class NavItem {
|
||||
|
||||
stage(callback) {
|
||||
// update if it's possible to go back from this nav item
|
||||
this.enableBack = !!this.navBase.getPrevious(this);
|
||||
this.enableBack = this.nav && !!this.nav.getPrevious(this);
|
||||
|
||||
if (this.instance) {
|
||||
// already compiled this view
|
||||
@@ -40,19 +40,19 @@ export class NavItem {
|
||||
}
|
||||
|
||||
// compile the Component
|
||||
this.navBase.compiler.compileInHost(this.ComponentClass).then(componentProtoViewRef => {
|
||||
this.nav.compiler.compileInHost(this.ComponentClass).then(componentProtoViewRef => {
|
||||
|
||||
// figure out the sturcture of this Component
|
||||
// does it have a navbar? Is it tabs? Should it not have a navbar or any toolbars?
|
||||
let itemStructure = getProtoViewStructure(componentProtoViewRef);
|
||||
|
||||
// get the appropriate Pane which this NavItem will fit into
|
||||
this.navBase.getPane(itemStructure, pane => {
|
||||
this.nav.getPane(itemStructure, pane => {
|
||||
|
||||
// create a new injector just for this NavItem
|
||||
let injector = this.navBase.injector.resolveAndCreateChild([
|
||||
bind(NavBase).toValue(this.navBase),
|
||||
bind(NavController).toValue(this.navBase.navCtrl),
|
||||
let injector = this.nav.injector.resolveAndCreateChild([
|
||||
bind(NavBase).toValue(this.nav),
|
||||
bind(NavController).toValue(this.nav.navCtrl),
|
||||
bind(NavParams).toValue(new NavParams(this.params)),
|
||||
bind(NavItem).toValue(this)
|
||||
]);
|
||||
@@ -63,7 +63,7 @@ export class NavItem {
|
||||
|
||||
let newLocation = new ElementRef(hostViewRef, 0);
|
||||
|
||||
this.setInstance( this.navBase.loader._viewManager.getComponent(newLocation) );
|
||||
this.setInstance( this.nav.loader._viewManager.getComponent(newLocation) );
|
||||
this.setViewElement( hostViewRef._view.render._view.rootNodes[0] );
|
||||
|
||||
this.disposals.push(() => {
|
||||
|
||||
Reference in New Issue
Block a user