Data-binding between nested polymer elements

前端 未结 3 1199
抹茶落季
抹茶落季 2020-12-14 22:04

Suppose I have two distinct polymer-elements

One should be embedded inside the other using the content placeholder. Is it possible to do

3条回答
  •  别那么骄傲
    2020-12-14 22:17

    Polymer data-binding works by attaching a model to a whole subtree.

    You wrote:

    
      
    
    

    this implies a rule that the parentNode provides the binding model. But now imagine you wanted to write:

    
      

    Now you have a problem.

    Instead, in Polymer examples, you will notice that the {{}} are (almost always) inside of a template. For example, if I define:

    
    
    
    

    Now, I have a model context (host-element) that I can use to bind things together in the entire subtree described by the template.

    Note that I don't need attributes="data" for this to work. I added that so host-element exposes data and I can do this:

      
    

    http://jsbin.com/IVodePuS/15/edit

提交回复
热议问题