2015-05-26 12 views
9

Zmagam się z migracją niestandardowego elementu, który używał rekurencyjnego wiązania szablonu w Polimerze 0,5. Kod HTML elementu niestandardowego wyglądał następująco:Wiązanie z szablonem rekurencyjnym z polimerem

<template> 
    <template bind="{{ items }}" id="t"> 
     <section id="{{ id }}" appName="{{ id }}"> 
      <template ref="t" repeat="{{ children }}"></template> 
     </section> 
    </template> 
</template> 

Jak napisać ten sam tekst w Polymer 0.9? czy ta funkcja nie jest jeszcze obsługiwana, czy planuje włączyć ją do przyszłych wersji Polymer?

Dzięki

Odpowiedz

10

Można zawierać element niestandardowy wewnątrz od siebie:

my-recursive.html

<link rel="import" href="../polymer/polymer.html"> 

<dom-module id="my-recursive"> 
    <template> 
    <template is="dom-repeat" items="{{data}}"> 
     <section id="{{item.id}}" appName="{{item.id}}"> 
     <my-recursive data="{{item.children}}"></my-recursive> 
     </section> 
    </template> 
    </template> 
</dom-module> 

<script> 
    Polymer({ 
    is: 'my-recursive' 
    }); 
</script> 

index.html

<my-recursive 
    data='[{"id":1,"name":"top1","children":[{"id":3,"name":"mid1","children":[]},{"id":5,"name":"mid3","children":[]}]},{"id":2,"name":"top2","children":[{"id":4,"name":"mid2","children":[]}]}]' 
></my-recursive> 
+0

miałem błąd: 'oczekiwana tablica dla przedmiotów, ', rozwiązane dzięki: http://stackoverflow.com/questions/31908958/dom-repeat-template-fails-to-render-array-with-error-expected-array-for-items – Thomas

Powiązane problemy