ionic-team / ionic-v3

The repo for Ionic 3.x. For the latest version of Ionic, please see https://github.com/ionic-team/ionic
Other
127 stars 85 forks source link

Back button does not change text dynamically #976

Open Wingzzzzz opened 5 years ago

Wingzzzzz commented 5 years ago

I'm submitting a ... (check one with "x") [x ] bug report

Current behavior: After setting back button text, it does not reflect right away in nav bar. Have to pop and push the page again. You can find the issue also stated in https://github.com/ionic-team/ionic/issues/7043

Expected behavior: Back button text changed after config changed

Steps to reproduce: In a page with nav-bar pushed by other page, change backButtonText to see if it change back button text right away

Related code: https://stackblitz.com/edit/backbuttonbug you can see can't change back button text instantly home tab -> contact -> to Chinese / English

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

Ionic:

   ionic (Ionic CLI)  : 4.8.0 (/usr/local/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.0

Cordova:

   cordova (Cordova CLI) : 8.1.1 (cordova-lib@8.1.0)
   Cordova Platforms     : android 7.1.4, browser 5.0.4, ios 4.5.5
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 1.2.1, (and 25 other plugins)

System:

   Android SDK Tools : 26.1.1 (/Users/chiuwingtsim/Library/Android/sdk)
   ios-deploy        : 1.9.4
   NodeJS            : v6.14.4 (/usr/local/bin/node)
   npm               : 3.10.10
   OS                : macOS High Sierra
   Xcode             : Xcode 10.1 Build version 10B61
Wingzzzzz commented 5 years ago

One workaround is to set view controller's back button text every time entered the page

wilk-polarny commented 5 years ago

You can also access the Navbar as a ViewChild. The navbar exposes the method setBackButtonText.

And regarding the method of the view controller:

Change the title of the back-button. Be sure to call this after ionViewWillEnter to make sure the DOM has been rendered.