How to do simple data binding with dom-repeat in Dart+polymer 1.0?


My brain hurts. (And sorry, I don’t know js).

For my simple example/learning curve, in my HTML file I have:

<template is="dom-repeat" items="{{datalist}}" as="item">

and in the Dart file:

List<String> datalist = new List();

void rebuildDatas() {

which does not show ‘hello’. But if I define:

List<String> data= ['one','two'];

‘one’ and ‘two’ are listed successfully.

How do I do a dynamic update of data please?

(rebuildDatas() is called of course!)




The version of Polymer you are using doesn’t support compound bindings.
This changed in Polymer 1.2 (JS) or Polymer Dart 1.0.0-rc.5.

The best action is to upgrade; an interim workaround would be to change this binding to span the whole text content of a tag:

<template is="dom-repeat" items="{{datalist}}" as="item">
  <!-- or   <div>{{item}}<div> -->

You need to use Polymer API to update property values in order for Polymer to recognize the change and update bound values:

List<String> datalist = new List();

void rebuildDatas() {
  add('datalist', 'hello');

See also Dart Polymer 1.0 – Two-way binding works?

Answered By – Günter Zöchbauer

Answer Checked By – Mary Flores (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.