HI! I've created a <custom-pager> element which dynamically creates polymer-element instances on the fly (instead of having to preload elements.) Ex (note, this is concept only, probably has bugs):
<polymer-element name="my-page1" attributes="attr1" noscript>
<template>
Page1 {{attr1}}
</template>
</polymer-element>
<polymer-element name="my-page2" attributes="attr2" noscript>
<template>
Page 2 {{attr2}}
</template>
</polymer-element>
<polymer-element name="custom-pager">
<template></template>
<script>
Polymer({
changePage(elementname, attrs) {
//...other code
var div = document.createElement('div');
div.innerHTML = '<' + elementname + '></' + elementname + '>';
for(var k in attrs) {
div.children[0][k] = attrs[k];
}
this.appendChild(div);
}
});
</script>
</polymer-element>
<custom-pager></custom-pager>
<script>
window.addEventListener('polymer-ready', function() {
document.querySelector('custom-pager').changePage('my-page1', {attr1: '{{boundvarfromelsewheredotcom}}'});
});
</script>
The issue is, i dont know which attributes the developer, using my custom-pager, needs to be passed + bound into the page "my-page1".
Question is, is there a way to have custom-pager automagically bind to all attributes so that they can be passed on to the pages (so one could specify <custom-pager attr1="{{attr1value}}" attr2="{{attr2value}}"/> )? Or is there a way to publish the attribute (per element instance, not prototype) on-the-fly (which would look like <custom-pager attr1="{{attr1value}}" attr2="{{attr2value}}" bindToAttributes="attr1 attr2"/> )?
Thanks peeps!
p4