5

I have this dom-repeat template and I wonder how to pass an Array into attribute.

<dom-module id="my-element">
  <template>
        <template is="dom-repeat" items="{{headers}}">
          <span>{{item}}</span>
        </template>
  </template>
</dom-module>

<script>
  Polymer({
    is: "my-element",
    properties: {
      headers: Array
    }
  });
</script>

and then in an index.html file, I bind it like this:

<my-element headers="['abc', 'def']"></my-element>

I tried doing that but I nothing happened and I got the warning Polymer::Attributes: couldn't decode Array as JSON

1 Answer 1

7

Switch the double and single quotes. Polymer 1.0 requires correct JSON quotes, in 0.5 the reverse was accepted (source).

<my-element headers='["abc", "def"]'></my-element>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.