It's not entirely clear what kind of stuff you want to pass in via `attrs`. Live code will help us figure out the details of your use case, so below is just a starting place.
As described, you can only pass in static data anyway, so I would start like so: http://jsbin.com/kibife/2/edit <polymer-element name="custom-pager"> <!-- for simplicity, let's leave out the template for now --> <script> Polymer({ changePage: function(elementname, attrs) { var page = document.createElement(elementname); for (var k in attrs) { page.setAttribute(k, attrs[k]); } // discard old page this.textContent = ''; this.appendChild(page); } }); </script> </polymer-element> <script> addEventListener('polymer-ready', function() { document.querySelector('custom-pager').changePage('my-page1', {attr1: 'boundvarfromelsewheredotcom'}); }); </script> On Fri, Sep 5, 2014 at 10:08 AM, Paul Hodges IV <[email protected]> wrote: > 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 > > Follow Polymer on Google+: plus.google.com/107187849809354688692 > --- > You received this message because you are subscribed to the Google Groups > "Polymer" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/polymer-dev/c649f93b-e859-4c07-8735-1c89c6fc0882%40googlegroups.com > <https://groups.google.com/d/msgid/polymer-dev/c649f93b-e859-4c07-8735-1c89c6fc0882%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > Follow Polymer on Google+: plus.google.com/107187849809354688692 --- You received this message because you are subscribed to the Google Groups "Polymer" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/CAHbmOLYDs%2BH-vWTm6V40csNGojA5RjoT_NaDtv45mj0cvT_-Tw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
