translate back button ionic 2

前端 未结 4 1540
[愿得一人]
[愿得一人] 2021-02-14 19:39

I changed the name of the Back button in ionic 2 but does somebody know how you can translate this button with ng2-translate?

this.config.set(\'backButtonText\',         


        
4条回答
  •  遥遥无期
    2021-02-14 20:36

    You can translate the back text like this, put on app.component.ts

    ngAfterViewInit() {
    this.navCtrl.viewWillEnter.subscribe((view) => {
      let parentView = this.navCtrl.getPrevious(view);
    
      if (parentView) {
        this.translate.get('nav.back.label').first().subscribe(
          moduleName => { this.navCtrl.getActive().getNavbar().setBackButtonText(moduleName); }
        );
      }
    }); }
    

提交回复
热议问题