Created
January 18, 2018 16:53
-
-
Save yukihane/5188f190a1fc595a89faa34cff72b492 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="ja"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<base href="https://polygit.org/components/"> | |
<script src="webcomponentsjs/webcomponents-lite.js"></script> | |
<link rel="import" href="polymer/polymer.html"> | |
<link rel="import" href="polymer/polymer-element.html"> | |
<link rel="import" href="polymer/lib/elements/dom-repeat.html"> | |
</head> | |
<body> | |
<component-a></component-a> | |
<dom-module id="component-a"> | |
<template> | |
<div><component-b json-data="[[receivedData]]"></component-b></div> | |
<div><button type="button" on-click="clickButton">データ取得</button></div> | |
</template> | |
<script> | |
class componentA extends Polymer.Element { | |
static get is() { | |
return 'component-a'; | |
} | |
static properties() { | |
return { | |
receivedData: { | |
type: Array, | |
} | |
} | |
} | |
constructor() { | |
super(); | |
} | |
clickButton(e) { | |
this.receivedData = JSON.parse('[{"name": "太郎"},{"name": "花子"}]'); | |
} | |
} | |
customElements.define(componentA.is, componentA); | |
</script> | |
</dom-module> | |
<dom-module id="component-b"> | |
<template> | |
<template is="dom-repeat" items="{{jsonData}}"> | |
<span>{{item.name}}</span> | |
</template> | |
</template> | |
<script> | |
class componentB extends Polymer.Element { | |
static get is() { | |
return 'component-b'; | |
} | |
static get properties() { | |
return { | |
jsonData: { | |
type: Array | |
} | |
} | |
} | |
constructor() { | |
super(); | |
} | |
} | |
customElements.define(componentB.is, componentB); | |
</script> | |
</dom-module> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment