【问题标题】:Ionic 2:How to use multi-lang for selector ion-select [selectOptions]?Ionic 2:如何将多语言用于选择器离子选择 [selectOptions]?
【发布时间】:2017-04-17 05:49:28
【问题描述】:
 <ion-item>
    <ion-label >{{ 'branch' | translate }}</ion-label>
    <ion-select [(ngModel)]="defualtBranch"  
    okText="{{ 'okText' | translate }}"
    cancelText="{{ 'cancelText' | translate }}" 
    [selectOptions]="{{ 'selectOptionsBranch' | translate }}"  >
      <ion-option *ngFor="let branch of branchs; let i=index" value="{{branch.BranchCode}}">
        {{branch.BranchName}}
      </ion-option>
    </ion-select>
  </ion-item>

如何使用 selectOptions 多语言?

不要在这条线上工作[selectOptions]="{{ 'selectOptionsBranch' | translate }}"

【问题讨论】:

    标签: android ios ionic2 cross-platform ionic2-select


    【解决方案1】:

    在 html 中将 [selectOptions]="{{ 'selectOptionsBranch' | translate }}" 更改为 [selectOptions]="selectOptionsBranch":

    在 Typescript 中使用此代码:

    import { TranslateService } from 'ng2-translate';
    export class IntroPage {
      selectOptionsBranch:any;
      constructor(public navCtrl: NavController,translate: TranslateService) {
        translate.use("fa");
        translate.get('selectOptionsBranch').subscribe(
          value => {
            console.log(value);
            this.selectOptionsBranch = value;
          }
        )
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2020-02-21
      • 2017-02-22
      • 2020-12-02
      • 2019-04-27
      • 2023-03-21
      • 2018-07-26
      • 2017-10-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多