0

Inside a polymer 1.0 custom element, I would like to iterate over an array an display its items with their content. All I get is an [object Object] tag, without displaying its content.

Is possible to achieve it without a computed function -like in this solution- iterating every item property and returning it as string?

My list iteration looks like:

<h4>My items:</h4>
<ol>
    <template is="dom-repeat" items="{{items}}">
      <li>{{item}}</li>
    </template>
</ol>

I did a plunker where you can reproduce it.

I saw there's an open issue referencing this feature.

Community
  • 1
  • 1
Mario Levrero
  • 3,345
  • 4
  • 26
  • 57

2 Answers2

0

You can't simple display data of javascript object. You have to do some transform/map its values to some text and/or element maybe.

See this plunker for a little snippet.

myData.forEach(function(i) {
        htmlResult.push('Item id:' + i.id);
      });
Mario Levrero
  • 3,345
  • 4
  • 26
  • 57
paYa
  • 231
  • 1
  • 7
0

You can display the id by

<li>{{item.id}}</li>

check the plunker

But that is not the requirement. I think Mario is asking for the entire object to come as string.

sounakpal
  • 106
  • 5