-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstub-demo.html
54 lines (49 loc) · 1.51 KB
/
stub-demo.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
44
45
46
47
48
49
50
51
52
53
54
<link rel="import" href="../polymer/polymer-element.html">
<dom-module id="stub-demo">
<script>
/**
* `stub-demo`
* Test examples
*
* @customElement
* @polymer
* @demo demo/stub-demo.html
*/
class StubDemo extends Polymer.Element {
static get is() { return 'stub-demo'; }
static get properties() {
return {
persons: {
type: Array,
value: [],
},
url: {
type: String,
value: 'http://www.json-generator.com/api/json/get/ceprBrYLCa?indent=2',
observer: 'urlChanged',
},
};
}
static get template() {
return Polymer.html`
<style>
:host {
display: block;
}
</style>
<template is="dom-if" if="[[persons]]">
<ul id="persons">
<template is="dom-repeat" items="[[persons]]" as="person">
<li>[[person.id]] -> [[person.name]]</li>
</template>
</ul>
</template>
`;
}
urlChanged(newUrl, oldUrl) {
fetch(newUrl).then(response => response.json()).then(persons => this.set('persons', persons));
}
}
window.customElements.define(StubDemo.is, StubDemo);
</script>
</dom-module>