如何在离子框架中更改后退按钮标题?

问题描述:

在Ionic Framework中,我在所有视图上使用此HTML结构:

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>

然后我会自动生成一个< Back按钮。但是,有时此按钮具有单词Back,有时它具有上一个视图的名称。

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?

你应该使用 $ 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');
});

此示例来自官方Ionic文档。

This example is from the official Ionic docs.

要控制后退按钮上的最后一个视图文本的行为,您可以将 backButton.previousTitleText(value)设置为false。

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