我在Aurelia中有一对Map,如下面的代码:
public intervals = new Map<number, { key: string}>();
this.intervals.set(1, {key: "immediately"});
this.intervals.set(2, {key: "eight-hours"});
this.intervals.set(3, {key: "seven-days"});
通过repeat.for我想为本地化目的设置一个上下文,如下所示:
<select class="combobox" value.bind="errorIntervall">
<option model.bind="null" t="network.empty">-</option>
<option repeat.for="[number, key] of intervals" t="system.network.intervall"
t-params.bind="{ context: key }">
></option>
</select>
这也是我的translation.json文件:
"network": {
"intervall_immediately": "Immediately",
"intervall_eight-hours": "every 8 h",
"intervall_seven-days": "every 7 days"
},
我没有找到任何方法来访问interval.key。 你能帮我吗?
答案 0 :(得分:1)
我解决了它,如下所示:
<select class="combobox" value.bind="errorIntervall">
<option model.bind="null" t="system.network.empty">-</option>
<option repeat.for="[number, interval] of intervals"
model.bind="interval"
t="system.network.interval"
t-params.bind="{ context: interval.key }">
></option>
</select>