Reputation: 2031
Should bindings created inside a template repeat
require an associated property on the polymer element, I thought they were bound to the array items of an ObservableList
?
Inside my template is the following code:
<polymer-element name="event-details">
<template>
<!-- etc -->
<template repeat="{{artist in event.artist}}">
<artist-card artist="{{artist}}">
</template>
<!-- etc -->
</template>
<!-- etc -->
</polymer-element>
And my element definition looks like
@CustomTag('event-details')
class EventDetails {
/* etc */
@published
api.Event get event => readValue(#event);
set event(api.Event event) => writeValue(#event, value);
/* etc */
}
When I create the element, I get the error
"EventDetails has no attribute `artist`"
but I assumed that the artist
in the <template repeat>
should only exist inside that template's scope. There is no value in having the {{artist}}
on the element's definition, as it will only ever point to the last element in the template's children.
artists
is an ObservableList
on the api.Event
object, although it is defined without using polymer.
Upvotes: 1
Views: 54
Reputation: 657308
Use a simple property (field/getter/setter) instead of readValue/writeValue.
Upvotes: 1