2016-03-07 46 views

回答

34

屬性backButtonText作爲離子鏈接提到離子2公測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', 
    } 
}) 

更新您可以設置後退按鈕的文字在你的app.html 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', 
}); 

離子2 rc.0和u UPDATE p以及離子3

在ionic 2 rc.0及更高版本中,我們需要包含app.module.ts下的imports數組。

@NgModule({ 
declarations: [ 
    MyApp, 
    Home 
], 
imports: [ 
    IonicModule.forRoot(MyApp, { 
     tabsPlacement: 'top', 
     backButtonText: 'Back' 
    })], 
bootstrap: [IonicApp], 
entryComponents: [ 
    MyApp, 
    Home ], 
providers: [MyService] 
}) 
+0

嗨。是否可以更改某個特定頁面的後退按鈕上的圖標和文本? – user3607282

+2

我還沒有嘗試過。只要看看http://ionicframework.com/docs/v2/api/components/nav/ViewController/#setBackButtonText setBackButtonText()。希望它有助於 – AishApp

0

我也沒有找到這方面的任何文件。但是我找到了設置按鈕文本和類的文件,所以你可以在那裏編輯它(它會改變每個頁面上的按鈕文本/類)。

變化node_modules/ionic-framework/config/modes.js

8

我剛剛花了一段時間去解決如何在離子2.

通過ViewController做這裏面你的頁面將輸出文件必須導入的ViewController

import { ViewController } from 'ionic-angular';

然後在你的構造函數中包含ViewController。

constructor(public viewCtrl: ViewController) {}

然後最後你可以調用函數更改文本。

ionViewDidLoad() { this.viewCtrl.setBackButtonText('Cancel'); }

我基本上從我會怎麼做了提醒和導航控制器的東西,所以我可能是錯的拼湊了一起。它雖然爲我工作,並有利於我允許每頁更改文本。

14

IONIC2的當前版本,您可以在全球範圍內改變後退按鈕的文字。

您還可以更改圖標就像它出現在iOS和隱藏"Back"標籤。

imports: [ 
    IonicModule.forRoot(MyApp,{ 
     backButtonText: '', 
     backButtonIcon: 'ios-arrow-back', 
     iconMode: 'md' 
    }) 
] 

就這一個添加到您的app.module.ts

+0

在當前版本「3.12.1」這是答案 –