在ng-repeat中迭代一个数组

时间:2018-04-12 18:57:13

标签: angularjs angularjs-ng-repeat

现在我有一个阵列。 即 var temp = [' 1234',' 1235',' 1236'];

我的html已遍历JSON对象但我想在表中添加一个只通过数组的列。例如,我设置了一个临时列,第一行应该有值1234,第二行应该有1235,最后一行应该有1236.有没有办法用ng-repeat做到这一点?

<tbody ng-repeat="ts in allInfo">
                                <td>
                                    {{ts.id}}
                                </td>
                                <td>
                                    {{ts.participant}}
                                </td>
                                <td>
                                    {{temp}} <-- each row should be the next value in the array.  Right now it outputs the whole array.
                                </td>
                                <td class="text-capitalize">
                                    {{ts.action}}
                                </td>
                    </tbody>

1 个答案:

答案 0 :(得分:1)

假设你的数组与你正在迭代的对象具有相同数量的元素,你可以使用ng-repeat的 [2018-04-12 15:00:18,770] ERROR {org.wso2.carbon.databridge.core.internal.queue.QueueWorker} - Dropping wrongly formatted event sent for -1234 org.wso2.carbon.databridge.core.exception.EventConversionException: Error when converting loganalyzer:1.0.0 of event bundle with events 1 at org.wso2.carbon.databridge.receiver.thrift.converter.ThriftEventConverter.createEventList(ThriftEventConverter.java:181) at org.wso2.carbon.databridge.receiver.thrift.converter.ThriftEventConverter.toEventList(ThriftEventConverter.java:90) at org.wso2.carbon.databridge.core.internal.queue.QueueWorker.run(QueueWorker.java:73) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: org.wso2.carbon.databridge.core.exception.EventConversionException: No StreamDefinition for streamId loganalyzer:1.0.0 present in cache at org.wso2.carbon.databridge.receiver.thrift.converter.ThriftEventConverter.createEventList(ThriftEventConverter.java:166) ... 7 more 变量来保存当前的迭代值。

如果您的对象可能包含重复的条目,您可能还想在ng-repeat语句中使用$index

track by