Binding and repeating over a list
In this recipe, we show you how the data of a list can be displayed in a Polymer component. So we perform data binding from the code to the UI here as well as in the following recipe. You can find the code for this recipe in the project databinding_list
.
How to do it...
- The script starts from
web\index.html
, where a component with the namepol-list
is imported through the line:<link rel="import"href="pol_list.html">
From this, we know that the component is defined in
pol_list.html
, and the code behind it is in a file namedpol_list.dart
. For a discussion of the other tags, see the previous recipe. - We define a list of companies that we want to display in the file
pol_list.dart
:import'dart:html'; import'package:polymer/polymer.dart'; @CustomTag('pol-list') classPollist extends PolymerElement { final List companies = toObservable(['Google', 'Apple', 'Microsoft', 'Facebook...