Skip to content

Instantly share code, notes, and snippets.

@AVGP
Created May 28, 2018 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AVGP/bf93ca42f27b922d75683ae40f37aa1f to your computer and use it in GitHub Desktop.
Save AVGP/bf93ca42f27b922d75683ae40f37aa1f to your computer and use it in GitHub Desktop.
A polymer 2 component using iron-ajax to load some data
<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