Note that there are some explanatory texts on larger screens.

plurals
  1. POObserving internal model attributes with Dart Polymer
    primarykey
    data
    text
    <p>I'm setting up custom Polymer elements that need to display data from the model (<code>Property</code> objects that need to be passed around).</p> <p>I can successfully display the values of the properties, but when I update a value inside a <code>Property</code> object, the value is not updated inside the element.</p> <p>What am I missing? I based myself on the following examples:</p> <p><a href="https://github.com/sethladd/dart-polymer-dart-examples/tree/master/web/bind_component_field_to_model_field" rel="nofollow">https://github.com/sethladd/dart-polymer-dart-examples/tree/master/web/bind_component_field_to_model_field</a></p> <p><a href="https://github.com/sethladd/dart-polymer-dart-examples/tree/master/web/getter_setter_as_attribute" rel="nofollow">https://github.com/sethladd/dart-polymer-dart-examples/tree/master/web/getter_setter_as_attribute</a></p> <p><strong>wb-control-text.html</strong></p> <pre><code>&lt;polymer-element name="wb-control-text"&gt; &lt;template&gt; &lt;div&gt; &lt;label for="{{id}}"&gt;{{label}}&lt;/label&gt; &lt;input type="text" id="{{id}}" value="{{value}}" /&gt; &lt;button on-click="{{updateValue}}"&gt;Update me&lt;/button&gt; &lt;/div&gt; &lt;/template&gt; &lt;script type="application/dart" src="wb-control-text.dart"&gt;&lt;/script&gt; &lt;/polymer-element&gt; </code></pre> <p><strong>wb-control-text.dart</strong></p> <pre><code>import "package:polymer/polymer.dart"; import "package:rqn_workbench/wb-property.dart"; @CustomTag("wb-control-text") class WorkbenchControlTextElement extends PolymerElement { final TextProperty _idProperty = new TextProperty("id", value: "1"); final TextProperty _valueProperty = new TextProperty("value", value:"Bla"); final TextProperty _labelProperty = new TextProperty("label", value:"Label!"); WorkbenchControlTextElement.created() : super.created(); @published String get id =&gt; _idProperty.value; void set id(String id) { _idProperty.value = id; } @published String get value =&gt; _valueProperty.value; void set value(String value) { _valueProperty.value = value; } @published String get label =&gt; _labelProperty.value; void set label(String label) { _labelProperty.value = label; } void updateValue() { value += "Bla"; print(value); // Will print the appended value } } </code></pre> <p><strong>wb-property.dart</strong></p> <pre><code>library workbench_property; import "package:polymer/polymer.dart"; @observable class Property { String key; } @observable class TextProperty extends Property { String value; TextProperty ( String key, {String value} ) { this.key = key; this.value = value; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload