【发布时间】:2018-09-28 23:41:12
【问题描述】:
我是 Angular 新手,我尝试将模块 ng2-completer 与 TranslateModule 一起使用。
问题是当我从服务器端检索 JSON 时,JSON 是:
[{"id":10,"tipo":"EUR"},{"id":20,"tipo":"USD"}]
我想使用 tipo 作为标签中的值
<ng2-completer #openCloseSelect
class="completer-limit"
[datasource]="dataService4"
[inputClass]="'form-control'"
[minSearchLength]="0"
[openOnFocus]="false"
[placeholder]="'SCEGLI' | translate"
[autoHighlight]="true"
[selectOnClick]="true"
[fillHighlighted]="false">
</ng2-completer>
其中“dataService4”在构造函数中被初始化为
this.dataService4 = completerService.local(this.diviseAzioni, "tipo", "tipo"); //diviseAzioni 是对象列表 class DivisaAzioni { 身份证号码; tipo: string;}(来自服务器端的 JSON)
并使用angular的TranslateModule来翻译tipo的值。
例如EUR: "Euro", USD: "US Dollars" 作为选择的 textLabel。
谢谢。
【问题讨论】:
标签: angular angular-translate ng2-completer