如何将数组从主机绑定到子节点

时间:2015-06-30 04:30:17

标签: javascript polymer web-component

我需要将数组作为参数从一个标签传递到另一个标签。正如您在代码中看到的那样,我试图将用户对象数组传递给子元素标记。但这并不奏效。那么如何将对象数组传递给嵌套标签呢? 第一个标签:     

  <template>
  </template> 
  <script>
    Polymer({
      is: "name-tag",
      ready: function() {
      this.user = {{name:"name0",surname:"surname0",age:23},{name:"name1",surname:"surname1",age:15},
      {name:"name2",surname:"surname2",age:65}}
        var toLight = document.createElement('child-element');
        toLight.setAttribute("users", this.user);
        Polymer.dom(this.root).appendChild(toLight);
      }
    });
  </script>

</dom-module>

**Second tag:**
<dom-module id="child-element">

    <template>
      The prop is <h1>{{users.0.age}}</h1> years old
      <h1>{{users.0.surname}}</h1>
</template>

<script>
  Polymer({
    is: 'child-element',
    properties:{
    users:{type:Object}}
  });
</script>

</dom-module>

1 个答案:

答案 0 :(得分:1)

试试这个例子。我想你帮忙

#include <stdint.h>

typedef uint8_t BYTE;
typedef uint32_t DWORD;
typedef int32_t LONG;
typedef int64_t LONGLONG;

typedef union _LARGE_INTEGER {
  struct {
    DWORD LowPart;
    LONG  HighPart;
  };
  struct {
    DWORD LowPart;
    LONG  HighPart;
  } u;
  LONGLONG QuadPart;
} LARGE_INTEGER, *PLARGE_INTEGER;