How to roll through a hash when you don't know the names in advance?

17 views
Skip to first unread message

Chris

unread,
May 15, 2013, 5:13:38 PM5/15/13
to transpa...@googlegroups.com
How do I get Transparency to display name/value pairs when you don't know the names in advance?

For example:

items: [
  {foo: "foo"},
  {foo: "foo", bar: "bar", bah: "bah"}
]


Template:

<div id="container">
  <div id="item">
    <span class="name"></span> <span class="value"></span>
  </div>
</div>

Output:

<div id="container">

    <div id="item">
      <span id="name">foo</span> <span class="value">foo</span>
    </div>

    <div id="item">
      <span id="name">foo</span> <span class="value">foo</span>
      <span id="name">bar</span> <span class="value">bar</span>
      <span id="name">bah</span> <span class="value">bah</span>
    </div>

</div>

Every item will have a different set of name/value pairs, and I don't know what they will be.

I'm sure there's a directive that will do this, but I can't quite wrap my head around it.

Message has been deleted

Mikko Ohtamaa

unread,
May 16, 2013, 3:04:04 AM5/16/13
to transpa...@googlegroups.com

Mikko Ohtamaa

unread,
May 16, 2013, 3:04:53 AM5/16/13
to transpa...@googlegroups.com
You should not use this kind of input data because iterating object property keys in JavaScript does not have stable order:

http://stackoverflow.com/a/5525820/315168


On Thursday, May 16, 2013 12:13:38 AM UTC+3, Chris wrote:
Reply all
Reply to author
Forward
0 new messages