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

[0.8] Feature request: computed properties in x-repeat #1337

Closed
morethanreal opened this issue Mar 26, 2015 · 9 comments
Closed

[0.8] Feature request: computed properties in x-repeat #1337

morethanreal opened this issue Mar 26, 2015 · 9 comments
Assignees

Comments

@morethanreal
Copy link
Contributor

I would like to use computed properties based on array data used in an x-repeat. For example, given data like this:

items: [
      {
        "type": "phone"
      },
      {
        "type": "email"
      }
]

I want to be able to do:

<template is="x-repeat" item="{{items}}">
    <core-icon icon="[[computeIconFromType(item.type)]]"></core-icon>
</template>
@chuckh
Copy link
Contributor

chuckh commented Mar 26, 2015

+1

@LorenzBischof
Copy link

+1 Is there a workaround yet?

ps: Issue #1337 :)

@mdwragg
Copy link

mdwragg commented Apr 7, 2015

👍 Needed here too +1 @robdodson - do you know a workaround?

@robdodson
Copy link
Contributor

@kevinpschaaf and @sorvell are the Polymer core wizards who might know secret black magic workarounds ✨

@kevinpschaaf
Copy link
Member

There are no good workarounds right now. This will definitely be done before 1.0, hopefully in 0.9 timeframe.

@dhubler
Copy link

dhubler commented Apr 8, 2015

why can't you use filter?

<core-icon icon="[[item.type | computeIconFromType]]"

[[computeIconFromType(item.type)]]
On Thu, Mar 26, 2015 at 2:06 PM Yvonne Yip notifications@github.com wrote:

I would like to use computed properties based on array data used in an
x-repeat. For example, given data like this:

items: [
{
"type": "phone"
},
{
"type": "email"
}
]

I want to be able to do:


Reply to this email directly or view it on GitHub
#1337.

@mdwragg
Copy link

mdwragg commented Apr 8, 2015

Does this not work either?

<span hidden$="[[!enabled]]">{{item.label}}</span>

in an x-repeat block? Where enabled is a property.

@mbleigh
Copy link

mbleigh commented Apr 14, 2015

As an alternative (or in addition), what about a map that lets you modify the items as you run through them:

<template is="x-repeat" map="prepareRepeat" items="[[users]]">
  <a href="[[item.profileLink]]">[[item.name]]</a>
</template>
<script>
  Polymer({
    prepareRepeat: function(user) {
      return {
        name: user.name,
        profileLink: "/users/" + user.id
      }
    }
  })
</script>

@kevinpschaaf
Copy link
Member

Closing, as inline computed binding support landed in #1422 and #1398.

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

No branches or pull requests

9 participants