Skip to content

Instantly share code, notes, and snippets.

@jaseflow
Last active March 30, 2016 10:40
Show Gist options
  • Save jaseflow/6eae808258eed935ba3bbd2a29abd996 to your computer and use it in GitHub Desktop.
Save jaseflow/6eae808258eed935ba3bbd2a29abd996 to your computer and use it in GitHub Desktop.
// Parent component which repeats a list style component (growth-units)
// If I observe "this.qualificationsList" I can see it updating when I add to it
// These updates do not seem to be passed down into "qual.units" for each repeated instance
<dom-module name="growth-template">
<template>
<template is="dom-repeat" items="[[ qualificationsList ]]" as="qual">
<growth-units
units="[[ qual.units ]]">
</growth-units>
</template>
</template>
<script>
Polymer({
is: "growth-template",
properties: {
qualificationsList: {
type: Array,
value: []
}
}
});
</script>
</dom-module>
// Child-Repeated list-style component with a repeater inside
// After intitial load, "this.units" loads the correct data.
// Although everytime the source for "this.units" is updated, it is not reflected in this component.
<dom-module name="growth-units">
<template is="dom-repeat" items="{{ _toArray(units) }}" as="unit">
<a>
<span>{{ unit.value.name }}</span>
<small>{{ unit.value.code }}</small>
</a>
</template>
<script>
Polymer({
is: "growth-units",
properties: {
units: {
type: Object,
value: {}
}
},
_toArray: function(obj) {
return Object.keys(obj).map(function(key) {
return {
name: key,
value: obj[key]
};
});
},
});
</script>
</dom-module>
@marcoslopes
Copy link

yo i don't think you can do that, the outside template is created only once and the internal templates then, can be updated...
i don't remember exactly where i have read that but that is i believe how it works, try something like...

 <template>
   <template is="dom-repeat" items="{{ _toArray(units) }}" as="unit">
      <a>
          <span>{{ unit.value.name }}</span>
          <small>{{ unit.value.code }}</small>
      </a>
    </template>
</template>

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