0

I've tried lots of options to get Firebase Key-indexed JSON to display db text and images (from storage) into divs and template by using getElementById and it works for only setting the elements of the last db record received for the template. But I'm trying a Polymer iron-list... and just can't get it.

I can't use iron-ajax since the firebase database url gives CORS header errors. I've tried creating a Polymer property Array that returns a function, but that works only for a hardcoded array that I manually removed to key from to test.

I've looked at Firebase Document and Firebase Collection, which refer to Firebase Query... but I can't figure out how to change oldData for newData in an observer function, and data's not going to change much, not yet anyway. And trying to set iron-list items = a Polymer property Array with a computed function option doesn't even get to invoke that part of the property code for some reason.

  1. How should Firebase Key-indexed JSON content be put automatically into a dom-repeat Tempate and into an Iron-list please?

It seems to go against grain to manipulate and iterate through the Object converted to Array in a for-loop like some answers suggest. But if the only option i would, what would be needed is to convert eg:

{"-KcKDbyGIwd.." :{ UserId : "Tri0IP..MruqLs1",desc : "king's horses"}, ..., {} }, to:

{ UserId : "Tri0IP..MruqLs1", desc : "king's horses"}, ..., {}

  1. How do I strip the key off each record please?

Thanks a lot in advance for your help...

verNsíon1
  • 53
  • 7

1 Answers1

0

This should work!

  <iron-list items="[[data]]" as="item">
    <template>
      <div>
        Name: [[item.name]]
      </div>
    </template>
  </iron-list>
JoelCode
  • 326
  • 1
  • 7
  • Hi Joel, thanks for replying... your approach works only from the Properties or from the ready function and the *data* in a HARD-CODED array WITHOUT the firebase push keys, the *data* appears... BUT can't get to see anything *automatically* ... the way *iron-list* or *dom-repeat template* work. ...BTW using *snapshot.forEach(function(childSnapshot)...* gives just the child without the push key. – verNsíon1 Feb 19 '17 at 00:42