2014-07-19 31 views
1

我有2個組件: x-container和x-item。 它們具有層次結構類似於<表>和當他們的x容器部件內部< TR>或< TR>和< TD> ... 因此X項組件是唯一有效的:聚合物:將屬性從容器組件傳遞到項目組件

<x-container> 
    <x-item></x-item> 
</x-container> 

我想通過從X-容器的X項目的屬性值:

<x-container att="value"> 
    <x-item></x-item> 
</x-container> 

在這種情況下,我需要的價值是X-項目可見 - 這可能嗎? 謝謝!

回答

1

它開箱的,如果你知道x-container事前(JSBin)的結構:

<polymer-element name="x-container" attributes="value"> 
    <template> 
    <x-item value="{{value}}"></x-item> 
    </template> 
    <script> 
    Polymer('x-container', { 
     value : null, 
     ready: function() { 
     } 
    }); 
    </script> 
</polymer-element> 

<polymer-element name="x-item" attributes="value"> 
    <template> 
    <div>x-item value:{{value}}</div> 
    </template> 
    <script> 
    Polymer('x-item', { 


    }); 
    </script> 
</polymer-element> 

<x-container value="test"></x-container> 

如果要動態創建的x-container的關係,x-item參考這些SO線程:

Data-binding between nested polymer elements

Using template defined in light dom inside a Polymer element

What is the best way to implement declarative collection rendering with Polymer?

相關問題