[英]How to use toLowerCase method in amp- mustache template variable
I am binding the amp-list with a JSON. 我将amp-list与JSON绑定。 The problem is I am providing the array element for amp-img and the src for amp-img must be in lower case as the asset on my server is in lowercase. 问题是我为amp-img提供了数组元素,而amp-img的src必须小写,因为服务器上的资产是小写的。
<amp-list layout="fixed-height" height= "10" [height]="getData().length * 50"
[src]="getData()" id="datalist" items=".">
<template type="amp-mustache">
<amp-img alt="image"
width="100"
height="100"
src="static/{{name}}.png">
// I want to use {{name.toLowerCase()}} here which is causing the problem
// Current src= "static/XYZ.png"
// Expected src= "static/xyz.png"
</amp-img>
</template>
</amp-list>
After trying multiple approaches, I achieved what I wanted to like this: [src]="'static/{{ name }}.png'.toLowerCase()"
在尝试了多种方法之后,我实现了自己想要的效果: [src]="'static/{{ name }}.png'.toLowerCase()"
Code Sample: 代码示例:
<amp-list layout="fixed-height" height= "10" [height]="getData().length * 50"
[src]="getData()" id="datalist" items=".">
<template type="amp-mustache">
<amp-img alt="image"
width="100"
height="100"
[src]="'static/{{ name }}.png'.toLowerCase()">
</amp-img>
</template>
</amp-list>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.