【发布时间】:2018-11-28 09:28:26
【问题描述】:
我需要使用状态作为 amp-list 的输入。但在此之前,我想映射状态(以执行一些数学或运算)。
将数组的每个位置映射到一个对象并放入src时,我无法使其工作(代码here):
<amp-list [src]="menu.array.map(x => ({size_new: x.size.toUpperCase(), color_new: x.color.toUpperCase()}))" width="auto" height="100">
<template type="amp-mustache">
<div>
{{size_new}} // {{color_new}}
</div>
</template>
</amp-list>
但是,如果我将每个数组位置映射到一个数组中(代码here),我可以让它工作:
<amp-list [src]="menu.array.map(x => [x.size.toUpperCase(), x.color.toUpperCase()])">
<template type="amp-mustache" width="auto" height="100">
<div>
{{0}} // {{1}}
</div>
</template>
</amp-list>
有什么建议吗?谢谢!
【问题讨论】:
标签: amp-html amp-list amp-bind