Created
May 28, 2018 09:23
-
-
Save AVGP/bf93ca42f27b922d75683ae40f37aa1f to your computer and use it in GitHub Desktop.
A polymer 2 component using iron-ajax to load some data
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
<link rel="import" href="../../bower_components/polymer/polymer-element.html"> | |
<link rel="import" href="../../bower_components/iron-ajax/iron-ajax.html"> | |
<dom-module id="polymer-playground-app"> | |
<template> | |
<iron-ajax auto url="https://jsonplaceholder.typicode.com/posts/1" handle-as="json" last-response="{{post}}"></iron-ajax> | |
<p>[[post.title]]</p> | |
</template> | |
<script> | |
/** | |
* @customElement | |
* @polymer | |
*/ | |
class PolymerPlaygroundApp extends Polymer.Element { | |
static get is() { return 'polymer-playground-app'; } | |
static get properties() { | |
return { | |
post: { | |
type: Object | |
} | |
}; | |
} | |
} | |
window.customElements.define(PolymerPlaygroundApp.is, PolymerPlaygroundApp); | |
</script> | |
</dom-module> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment