2

I need to create polymer custom element with binding attribute.

<foo-bar baz="{{qux}}"></foo-bar>

It's OK. But it must be created dynamically (tagName passed as an attribute). I try this

Polymer({
    ready: function() {
        var element = document.createElement(this.tagName);
        element.setAttribute('baz', '{{qux}}');
        this.$.placeholder.appendChild(element);
    }
});

But it does not work. How can I do that?

Johan
  • 163
  • 2
  • 6

1 Answers1

3

You can do this with injectBoundHTML():

<div id="container"></div>

...

this.injectBoundHTML('<foo-bar baz="{{qux}}"></foo-bar>', this.$.container);

It's not documented yet, but more info is here: https://github.com/Polymer/docs/issues/607

ebidel
  • 23,921
  • 3
  • 63
  • 76