Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the ion-back-button not shown?

The ion-back-button does NOT show up to the right of the ion-menu-button. Why is that?

the ion-menu-button and the ion-title show properly and aligned on the same horizantal position.

<ion-header>
  <ion-toolbar>

    <ion-buttons slot="start">
      <!-- navigation button-->
      <ion-menu-button></ion-menu-button>
      <!-- optional back button-->
      <ion-back-button></ion-back-button> 
    </ion-buttons>

    <ion-title>
        {{ pageTitle | translate}}
    </ion-title>

  </ion-toolbar>
</ion-header>

In the DOM inspector the CSS display attribute of the ion-back-button is set to none. Why would it set itself to none?

I used

this.navCtrl.navigateForward('/term/' + term);

to navigate to this page, thus I expect the back button to pick this up. Why is navigateForward not adding to the stack, which would make the ion-back-button show?

like image 283
feder Avatar asked Oct 25 '19 17:10

feder


People also ask

How do I add a back button in Ionic?

We can change and control what to display in the back button, we can use the text and icon properties. Here is a screenshot of the slot attribute used ionic back button. The slot can be left or right and by default, it is left. Let add back button for about page template.

How do I use the Ion menu button?

The Ionic menu toggle can be used to open and closed the menu. Menu toggle is only visible when the selected menu is active. When it is opened or closed, the menu is active. If the menu is hidden or displayed as a split-pane, then the menu is marked as inactive, and <ion-menu-toggle> componenthides.

How do you handle the back button in Ionic 3?

In Android application we generally press/ tap back to go back view or page but in root activity or root page in Ionic application this back press operation closes or minimize the application to the recent list.


2 Answers

If there is no page in Stack then

<ion-back-button></ion-back-button>

will not show. If you want to show then You need to be added a specific page in "defaultHref" Attribute.

<ion-back-button defaultHref="logout"></ion-back-button>

you need to be learned from here

https://ionicframework.com/docs/api/back-button

like image 80
Hassan Ali Avatar answered Oct 23 '22 14:10

Hassan Ali


It will not visible if there will be no previous overlay/page to show

So you can set css

ion-back-button {
   display: block;
}

Then add click event on element

<ion-back-button (click)="close()">
    <ion-icon name="close"></ion-icon>
</ion-back-button>

Add on .ts file

click() {
  this.modalCtrl.dismiss();
}
like image 11
Kathrecha Krishna Avatar answered Oct 23 '22 16:10

Kathrecha Krishna