【问题标题】:Ionic 3 modal display messageIonic 3 模态显示消息
【发布时间】:2018-03-15 20:07:41
【问题描述】:

我已经设计了 Ionic 3 模态。现在我想显示一些消息(Hello Modal)。如何在模态框内显示消息? 下面是我的 openModal 代码。

openModal() {
    const myModal = this.modal.create('ModalPage');
    myModal.present();
}

我想使用翻译显示消息。就我而言,消息将设置在 en.json 文件中,并且我需要从那里调用 HTML 文件中的消息。这就是我卡住的地方。

在 ionic 1 中,我有类似的东西,

$translate(['USER_DATA']).then(function(translations) {
                        vm.userData=translations.USER_DATA; 
}

我将在我的 HTML 中调用vm.userData,它将以模式显示消息。如何在 ionic 3 中实现相同的翻译代码

【问题讨论】:

标签: modal-dialog ionic3


【解决方案1】:

就这么简单。

import {TranslateService} from '@ngx-translate/core';
...
constructor(private translate : TranslateService) 
...
this.translate.setDefaultLang('en');

这只是一个概述。请浏览此link 以获得更好的想法。

他们已经清楚地解释了 en.json 文件的放置位置以及如何使用它。

快乐编码。

【讨论】:

    【解决方案2】:
    this.translate.get('here your message u want to translate').subscribe(res => {          
         const myModal = this.modal.create('ModalPage',res);
         myModal.present();
    })
    

    在 modalpage 中通过 'params.data()' 获取翻译后的消息并根据需要显示

    【讨论】:

      猜你喜欢
      • 2017-01-03
      • 1970-01-01
      • 2020-05-08
      • 2016-10-27
      • 2018-03-03
      • 2019-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多