[英]printing the DOM array through dom-repeat
I have one Array graphData . 我有一个Array graphData 。 Now I want to use dom-repeat to print it.
现在,我想使用dom-repeat进行打印。
<template is='dom-repeat' items='{{internalgraphData}}'>
<tr>
<td>{{item.asset}}</td>
<td>{{item.percentage}}%</td>
<td>{{item.investment}}</td>
<td>{{item.currentvalue}}</td>
<td class="u-value-align"><span class="red-text darken-4">{{item.gain}}</span></td>
<td><img src="../images/arrow-red.png"></td>
<td class="black-text"><a class="waves-effect waves-light btn white blue-text back" href="equity.html">Select</a></td>
</tr>
</template>
My json is as below... I tried to create the dom-repeat structure with below tag-value "internalgraphData" I printed internalgraphData, it looks I successfully transferred the data from json to local tag-value structure "internalgraphData" 我的json如下所示:我尝试使用下面的标签值“ internalgraphData”创建dom-repeat结构,并打印了internalgraphData,看起来我已成功将数据从json传输到了本地标签值结构“ internalgraphData”
Polymer({ is: 'my-menu',
........
ready : function(graphid,graphData) {
this.graphData = [
['Equity', 50,25000,37000,240],
['Bonds', 35,12500,10000,-480],
['Alternates',5, 2000,2000,340],
['Cash',10,1000,1000,-140]
];
if (this.graphData.length > 0)
{
for(i = 0; i< this.graphData.length; i++)
{
this.internalgraphData.push({
"asset" : this.graphData[i][0],
"percentage" : this.graphData[i][1],
"investment" : this.graphData[i][2],
"currentvalue" : this.graphData[i][3],
"gain" : this.graphData[i][4]
});
}
But I see that the dom-repeat is not printing . 但是我看到dom-repeat不能打印。 Could anyone help how can we achieve that?
谁能帮助我们实现这一目标?
NOTE: If I add the tag-value explicitly... the table is coming... 注意:如果我显式添加标记值...表将要出现...
this.internalgraphData = [
/*['Equity', 50,25000,37000,240],
['Bonds', 35,12500,10000,-480],
['Alternates',5, 2000,2000,340],
['Cash',10,1000,1000,-140]*/
{asset: 'Equity', percentage: 50, investment: 25000, currentvalue: 37000, gain: 240 },
{asset: 'Equity', percentage: 35, investment: 12500, currentvalue: 10000, gain: -480 },
{asset: 'Equity', percentage: 5, investment: 2000, currentvalue: 2000, gain: 340 },
{asset: 'Equity', percentage: 10, investment: 1000, currentvalue: 1000, gain: -140 }
];
this.internalgraphData.push({});
above operations in loop doesn't reflect in polymer data-change.Below is the recommended way to object in array. 上面的循环操作不能反映聚合物数据的变化。下面是推荐的数组对象的方法。
this.push('internalgraphData', {title:'hey'});
if you can't do this way. 如果您不能这样做。 please use below way
请按以下方式使用
this.updatedgraphData = JSON.parse(JSON.stringify(this.internalgraphData ));
use dom-repeat over ***updatedgraphData***
在
***updatedgraphData***
使用dom-repeat
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.