How to change the label of back button in Ionic 4?

Viewed 721

Given a multi language Ionic 4 application. User can select the language.

How can I change (or more like), how can the text set to be dynamic ?

This is how far I got - but of course this isn't working:

<ion-back-button [text]="{{ app.button.back | translate }}"></ion-back-button>

UPDATE: I meant by not working, I get the following error:

Parser Error: Got interpolation ({{}}) where expression was expected at 
column 0 in [{{ app.button.back | translate }}]
3 Answers

You are combining two features here:

[text]="{{ app.button.back | translate }}"

You just need to remove the [] so its not expecting a javascript value:

<ion-back-button text="{{ 'app.button.back' | translate }}"></ion-back-button> 

You can use this method in ionic 4:

 <ion-back-button [defaultHref]="defaultHref" slot="start" text="{{ 'SIGNUP.BACK' | translate }}">

In ionic 6 you can use a small hack:

const Ionic = (window as any as IonicWindow).Ionic;
(Ionic.config as Map<string, string>).set("backButtonText","MyBackText");
Related