通过dom-repeat打印DOM数组

时间:2016-08-04 11:02:22

标签: javascript node.js polymer

我有一个数组 graphData 。现在我想用dom-repeat打印它。

org.springframework.integration.handler.AbstractMessageProducingHandler.produceOutput(AbstractMessageProducingHandler.java:212)
    at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutputs(AbstractMessageProducingHandler.java:129)
    at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:115)
    at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127)
    at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:160)
    at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:121)
    at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)
    at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:423)
    at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:373)
    at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:115)
    at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:45)
    at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:105)
    at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutput(AbstractMessageProducingHandler.java:292)
    at org.springframework.integration.handler.AbstractMessageProducingHandler.produceOutput(AbstractMessageProducingHandler.java:212)
    at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutputs(AbstractMessageProducingHandler.java:129)
    at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:115)
    at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127)
    at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:160)
    at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:121)
    at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)
    at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:423)
    at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:373)
    at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:115)
    at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:45)

我的json如下所示...我尝试使用下面的tag-value" internalgraphData"创建dom-repeat结构。 我打印了internalgraphData,它看起来我成功地将数据从json传输到本地标签值结构" internalgraphData"

<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>

但是我看到dom-repeat没有打印。 任何人都可以帮助我们如何实现这一目标?

注意:如果我明确地添加了标签值......表即将来临......

 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]

                                    }); 
                                }

1 个答案:

答案 0 :(得分:1)

this.internalgraphData.push({});

循环中的上述操作并未反映聚合物数据变化.Below是数组中对象的推荐方法。

<强> this.push('internalgraphData', {title:'hey'}); 如果你不能这样做。请使用以下方式

this.updatedgraphData  = JSON.parse(JSON.stringify(this.internalgraphData ));

***updatedgraphData***

上使用dom-repeat