...">

Data binding for a dynamically created item

In the 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?

+3


source to share


2 answers


You can watch



there was a similar question in Polymer.js 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 already quite late ...

I created this issue http://dartbug.com/21029 It has now been fixed with injectBoundHtml

. See https://groups.google.com/a/dartlang.org/d/msg/web/uqri0fpGH10/dPm169WUiUwJ for details .

+2


source


I am using 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 complicated to me and I haven't found a more elegant solution yet.

I'm confused by Gunther's phrase "The expressions used must already be used somewhere, so Smoke knows how to generate code for them." from Dart: dynamic use of polymer ui-tabs and polymer-ui pages doesn't work . Could anyone on this thread spark this point?

0


source







All Articles