-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlesson-0041-component.html
43 lines (36 loc) · 1.27 KB
/
lesson-0041-component.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<dom-module id="employee-list">
<template>
<p> Employee list: </p>
<template is="dom-repeat" id="employeeList" items="{{employees}}">
<div>First name: <span>{{item.first}}</span></div>
<div>Last name: <span>{{item.last}}</span></div>
<button on-click="toggleSelection">Select</button>
</template>
<array-selector id="selector" items="{{employees}}" selected="{{selected}}" multi toggle></array-selector>
<p> Selected employees: </p>
<template is="dom-repeat" items="{{selected}}">
<div>First name: <span>{{item.first}}</span></div>
<div>Last name: <span>{{item.last}}</span></div>
</template>
</template>
<script>
Polymer({
is: 'employee-list',
ready: function() {
this.employees = [
{first: 'Bob', last: 'Smith'},
{first: 'Sally', last: 'Johnson'},
{first: 'sh', last: 'Nam'},
{first: "Jack", last: "Aubrey" },
{first: "Anne", last: "Elliot" },
{first: "Stepehen", last: "Maturin" },
{first: "Emma", last: "Woodhouse" }
];
},
toggleSelection: function(e) {
var item = this.$.employeeList.itemForElement(e.target);
this.$.selector.select(item);
}
});
</script>
</dom-module>