Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

template object keys #1062

Closed
gertcuykens opened this issue Jan 1, 2015 · 7 comments
Closed

template object keys #1062

gertcuykens opened this issue Jan 1, 2015 · 7 comments
Labels

Comments

@gertcuykens
Copy link

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys

rows = [{
  "field1":"test1",
  "field2":"test2",
  "field3":"test3",
  "field4":"test4"
}]

<template repeat="{{row in rows}}">
  <template keys="{{key in row}}">
   {{key}} :  {{row[key]}} </br>
  </template>
</template>

So I can solve this
http://stackoverflow.com/questions/27724788/polymer-template-repeat-field-names

@davidmaxwaterman
Copy link

Did the getKeys method that was mentioned in reply to your SO question not work for you?

@gertcuykens
Copy link
Author

Yes, but still wondering if making a template keys=... would be a better solution or not ? If getKeys is considered the best option instead of a new template keys=... feature then this can be closed.

@gertcuykens
Copy link
Author

found a issue

<template repeat="{{i in keys(obj)}}">
</template>

wil not detect changes to obj

@pflannery
Copy link

This plunker shows two examples:

  1. How to refresh a repeat using a filter parameter. Less overhead and simple to implement. It's recommended to use event actions over observers where possible,
  2. How to observe an Object as an Array (based from this issue comment Should be able to <template repeat> on object values, Maps just like we do on array values. googlearchive/polymer-expressions#11 (comment))

@gertcuykens
Copy link
Author

Ok I understand the example thanks, using observers is indeed to complex

@ryantheleach
Copy link

@pflannery Is there anyway to work this into a component to make it easier to use?

@tjsavage
Copy link
Contributor

Closing this issue due to age and the release of version 1 of Polymer - please feel free to re-open if this is incorrect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants