Reputation: 1018
In a polymer element I can bind a property like this:
<input type="text" value="{{value}}">
But if I create the html element dynamically in the script:
TextInputElement newElement = new TextInputElement();
How can I achieve the binding?
Upvotes: 3
Views: 676
Reputation: 7641
I use this workaround (polymer 0.15.5+4):
var template = new TemplateElement()
..setInnerHtml("<p>Reversed: {{ reversed }}</p>");
var fragment = this.instanceTemplate(template);
this.shadowRoot.append(fragment);
But it seems rather complex for me and i've not found more elegant solution for a while.
I feel confused by Günter's phrase "The used expressions must already be used somewhere so Smoke knows to generate code for them." from Dart: Dynamic usage of polymer-ui-tabs and polymer-ui-pages does not work thread. Can somebody from this thread light this moment?
Upvotes: 0
Reputation: 658067
You can have a look at
there was a similar question for Polymer.js recently with a simpler solution (Data binding for dynamically generated HTML in Polymer?) but I haven't seen anything similar for Polymer.dart yet.
I'll try to find something tomorrow, it's rather late here already ...
I created this issue http://dartbug.com/21029
This is fixed now with injectBoundHtml
.
See also https://groups.google.com/a/dartlang.org/d/msg/web/uqri0fpGH10/dPm169WUiUwJ for more details.
Upvotes: 2