离子3导航控制器后退按钮没有显示

时间:2018-05-29 07:21:58

标签: javascript ionic3

从推送通知中打开已关闭的应用时,后退按钮不会显示在导航栏中。如果应用程序已打开,则会出现按钮。

我尝试检查navController长度,如果长度为0,则插入页面。但后退按钮仍未显示。

有关如何使其正常工作的任何提示?

<ion-header>
  <ion-navbar>
    <ion-title>
      Title
    </ion-title>
  </ion-navbar>
</ion-header>

constructor(navCtrl: NavController) {

  let lastNavLength = navCtrl.length();

  if (lastNavLength == 0) {
    console.log('empty');
    navCtrl.insert(0, TabsPage);
  }

}

app.component.ts

  private onPushOpened(payload: OSNotificationPayload) {
    if (payload.additionalData.eventKey) {
      this.notificationOpen = true;
      this.appCtrl.getRootNav().push('EventPage', {
        id: payload.additionalData.eventKey,
        event: payload.additionalData.event,
        action: 'tapped'
      });
    }
  }

--------------编辑--------------------

app.component.ts

  private onPushOpened(payload: OSNotificationPayload) {
    if (payload.additionalData.eventKey && payload.additionalData.event) {

      this.notificationOpen = true;
      this.appCtrl.getRootNav().push('event', {
        id: payload.additionalData.eventKey,
        event: payload.additionalData.event,
      });
    }
  }

tabs.module.ts

import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { TabsPage } from './tabs';

@NgModule({
    declarations: [
        TabsPage,
    ],
    imports: [
        IonicPageModule.forChild(TabsPage),
    ],
})
export class TabsPageModule { }

tabs.ts

import { Component } from '@angular/core';
import { IonicPage } from 'ionic-angular';

@IonicPage({
  name: "TabsPage",
  segment: "tabs",
})
@Component({
  templateUrl: 'tabs.html'
})

export class TabsPage {

  tab1Root = 'HomePage';
  tab2Root = 'AboutPage';
  tab4Root = 'SettingsPage'

  constructor() {

  }
}

home.ts

@IonicPage({
  name: 'HomePage',
  segment: 'home'
})
@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})

event.ts

@IonicPage({
  name: 'EventPage',
  defaultHistory: ['HomePage'] .. tried with TabsPage also.
})
@Component({
  selector: 'page-event',
  templateUrl: 'event.html',
})

0 个答案:

没有答案