相关疑难解决方法(0)

聚合物Dom-Repeat绑定到内容

在聚合物1.2.3中,是否可以dom-repeat使用内容作为模板并将值绑定到所提供的元素?

自定义元素:

<dom-module id="modify-collection">
  <template>
    <div>
      <template is="dom-repeat" items="[[collection]]">
        <content></content>
      </template>
    </div>
  </template>
</dom-module>
Run Code Online (Sandbox Code Playgroud)

用法:

<modify-collection collection="{{things}}">
  <list-item resource="[[item]]"></list-item>
</modify-collection>
Run Code Online (Sandbox Code Playgroud)

我在没有帮助的情况下查看了以下资源:

Polymer:如何监视<content>属性的变化

Polymer 1.0模板绑定ref等效

嵌套聚合物元素之间的数据绑定

https://github.com/grappendorf/grapp-template-ref

https://github.com/Trakkasure/dom-bindref

https://github.com/Polymer/polymer/issues/1852

https://github.com/Polymer/polymer/pull/2196


更新2016-02-03:从聚合物团队(PR#2196),计划在未来更好地支持这一点,以帮助解决一些缺点.

polymer polymer-1.0

19
推荐指数
2
解决办法
7006
查看次数

嵌套聚合物元素之间的数据绑定

假设我有两个截然不同的 polymer-elements

一个应该使用content占位符嵌入另一个内部.是否有可能在这两个嵌套之间进行数据绑定polymer-elements

我试过了,但我无法让它工作:http://jsbin.com/IVodePuS/11/

根据http://www.polymer-project.org/articles/communication.html#bindingpolymer-elements应该工作之间的数据绑定(在这些示例中,它们是在template标记内完成而不使用content占位符).

更新:

斯科特迈尔斯澄清说,数据绑定只适用于该template级别.
但是在我的情况下,我template事先并不知道确切的但是我想允许我的用户parent-element指定child-element它应该包含哪些(假设有不同的child-elements.
我认为这个问题与这个问题有关:使用在光dom中定义的模板在Polymer元素中

我更新了以下示例以突出显示他:

<polymer-element name="parent-element" >
  <template >
    <div>Parent data: {{data1}} </div>
    <content />
  </template>
  <script>
    Polymer('parent-element', {
      data1 : '',
      ready: function() {
        this.data='parent content';
      }
    });

  </script>
</polymer-element>

<polymer-element name="child-element" attributes="data2">
   <template>
    <div>Parent data: {{data2}} </div>
  </template>
  <script>
    Polymer('child-element', {
      data2 : '',
      ready: function() { …
Run Code Online (Sandbox Code Playgroud)

data-binding web-component shadow-dom polymer

13
推荐指数
1
解决办法
1万
查看次数