2014-09-30 91 views
0

内我有一个看起来像这样的元素:聚合物:模板重复阵列阵列

<polymer-element name="page-slides"> 
    <template> 
    <template repeat="{{row in slideContainer}}"> 
     <ul class="slide-container"> 
     <template repeat="slide in row"> 
      <li class="slide">{{slide.foo}}</li> 
     </template> 
     </ul> 
    </template> 
    </template> 
    <script> 
    Polymer('page-slides', { 
     ready: function() { 
     this.slideContainer = []; 
     for (i = 0; i < 2; i++) { 
      this.slideContainer.push([]); 
      for (j = 0; j < 2; j++) { 
      this.slideContainer[i].push({foo: "foo", bar: "bar"}); 
      } 
     } 
     } 
    }); 
    </script> 
</polymer-element> 

所以基本上我有一个数组的数组中,我试图来生成每一个新的UL slideContainer中的数组,以及数组中每一组属性的新li。

这不,虽然工作,我可以通过这种更换模板访问信息的阵列的内部,所以我知道数据是存在的:

<template repeat="{{row in slideContainer}}"> 
     <ul class="slide-container">> 
     <li class="slide">{{row[0].foo}}</li> 
     </ul> 
    </template> 

我在做什么错?

回答

2

你错过{{}}周围的重复:

<template repeat="{{slide in row}}">