googlearchive / core-list

Polymer virtualized list element
25 stars 23 forks source link

Consider support stringified data. #23

Open davidmaxwaterman opened 10 years ago

davidmaxwaterman commented 10 years ago

From reading this :

http://www.polymer-project.org/docs/start/usingelements.html#objectarray

"many Polymer elements understand attribute values that are a JSON-serialized object or array."

and the example here :

http://www.polymer-project.org/docs/elements/core-elements.html#core-list

I was expecting to be able to combine them and add this in a plain index.html file (with the core-list import, of course) :

<core-list data="[{"name": "John"}, {"name": "Bob"}]" height="80">
  <template>
    <div class="{{ {selected: selected} | tokenList }}">
      List row: {{index}}
      Name: {{name}}
    </div>
  </template>
</core-list>

However, core-list won't deserialise the json, so I have to create another polymer element in order to use it.

A bit of a side-issues: I was also wanting to put data="{{data}}" there, and have an input element with value="{{data}}", and have them be bound together. I think this expectation originates from other frameworks where you can bind attributes together like this (was it angular that is a bit like this). I wonder if it is possible...

steve-the-edwards commented 10 years ago

+1. Yes - i'd like to do the same thing.

Edit: I think this is actually currently doable, and seems to work fine.