user101010
user101010

Reputation: 117

Polymer 1.0 data binding options for accessing lists

In Polymer 1.0, is it possible to do:

{{ object in house.animals }}

where house.animals is a list? In the documentation, I found only simple examples in the binding, like {{ animals }}.

Upvotes: 0

Views: 29

Answers (1)

tony19
tony19

Reputation: 138686

It looks like you're trying to change the name of the iterator to "object", which can be done by setting the <dom-repeat>.as property (i.e., as="object").

And yes, you can bind <dom-repeat>.items to a subproperty of an object as long as the subproperty is an Array.

<template is="dom-repeat" items="{{house.animals}}" as="{{object}}">
  <div>Type: {{object.type}}</div>
</template>

demo

Upvotes: 2

Related Questions