Question

I have yet another question: Why is that if I repeat over a list of objects from a template the element in the template cannot see the object when used declaratively?

artists = [ {name: 'whatever',..},...];

Example:

<template repeat="{{a in artists}}">
  <artist-record model="{{a}}"></artist-record>
</template>

If I do the same imperatively it works

Example

artists.forEach(function(a) {
  var node = document.createElement('artist-record');
  node.model = a;
  this.$.container.appendChild(node);
}, this);

Is there a way to do this declaratively?

Was it helpful?

Solution

This works for me: http://jsbin.com/zemawugu/1/edit

Check that your array assignment is to this.artists and not artists. The binding system needs that array to be on the element prototype for the template to see it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top