Reputation: 301
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?
Upvotes: 2
Views: 965
Reputation: 24109
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
Upvotes: 3