Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Latest commit

 

History

History

looping_over_a_collection_using_iterative_templates

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Looping over a collection using iterative templates

Shows iterating over a list of items using template repeat.

The code

How it works

The MyElement class (my_element.dart) defines a list of fruits:

@property final List<String> fruits = 
    ['apple', 'banana', 'fig', 'kiwi', 'guava'];

In the template code (my_element.html), template repeat iterates over the list of fruit, rendering each with a template:

<template is="dom-repeat" items="{{fruits}}">
    <div>{{item}}</div>
</template>

or

<template is="dom-repeat" items="{{fruits}}" as="fruit">
    <div>{{fruit}}</div>
</template>

More information