Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the label from back button in Ionic 2?

With the code:

<ion-navbar *navbar>
</ion-navbar>

the back button is enabled. But I need to customize it (the icon or the label). Is it possible? Can't find anything in the docs/api.

like image 232
Christian Benseler Avatar asked Mar 07 '16 18:03

Christian Benseler


1 Answers

you can set back button text in your app.html as mentioned in the ionic link http://ionicframework.com/docs/v2/api/config/Config

@App({
  template: `<ion-nav [root]="root"></ion-nav>`
  config: {
    backButtonText: 'Go Back',
    iconMode: 'ios',
    modalEnter: 'modal-slide-in',
    modalLeave: 'modal-slide-out',
    tabbarPlacement: 'bottom',
    pageTransition: 'ios',
  }
})

UPDATE in ionic 2 beta 8

import {ionicBootstrap} from 'ionic-angular';

ionicBootstrap(AppRoot, customProviders, {
  backButtonText: 'Go Back',
  iconMode: 'ios',
  modalEnter: 'modal-slide-in',
  modalLeave: 'modal-slide-out',
  tabbarPlacement: 'bottom',
  pageTransition: 'ios',
});

UPDATE in ionic 2 rc.0 and up, as well as ionic 3

In ionic 2 rc.0 and up, we need to include the configs in app.module.ts under imports array.

@NgModule({   
 declarations: [
    MyApp,
    Home   
 ],   
 imports: [
    IonicModule.forRoot(MyApp, {
      tabsPlacement: 'top',
      backButtonText: 'Back'
     })],
 bootstrap: [IonicApp],
 entryComponents: [
    MyApp,
    Home   ],
 providers: [MyService]
})
like image 157
AishApp Avatar answered Nov 15 '22 23:11

AishApp