How can I change the back button title in ionic fr

2019-04-24 17:50发布

In Ionic Framework, I use this HTML structure on all my views:

 <ion-view view-title="Some title">
    <ion-nav-buttons>
    </ion-nav-buttons>
 <ion-content>

Then I get a "< Back" button generated automatically. However, sometimes this button has the word "Back" and sometimes it has the name of the previous view.

Where and how can I change how the back button title behaves?

2条回答
贪生不怕死
2楼-- · 2019-04-24 18:05

In Ionic Framework 2 you could now use the set the config property backButtonText to ''

@NgModule({
  declarations: [ MyApp ],
  imports: [
    IonicModule.forRoot(MyApp, {
      backButtonText: '',
    }, {}
  )],
  bootstrap: [IonicApp],
  entryComponents: [ MyApp ],
  providers: []
})
查看更多
小情绪 Triste *
3楼-- · 2019-04-24 18:21

You should use the $ionicConfigProvider:

var myApp = angular.module('reallyCoolApp', ['ionic']);

myApp.config(function($ionicConfigProvider) {
  $ionicConfigProvider.views.maxCache(5);

  // note that you can also chain configs
  $ionicConfigProvider.backButton.text('Go Back');
});

This example is from the official Ionic docs.

To control the behaviour of the "last view text on back button" you could set backButton.previousTitleText(value) to false.

查看更多
登录 后发表回答