This example creates a Polymer element named x-foo
, whose template binds to a string property, named "message". The element's HTML is imported into the main document, which allows usage of <x-foo>
tags in <body>
.
x-foo.html
<dom-module id="x-foo">
<template>
<span>{{message}}</span>
</template>
<script>
Polymer({
is: 'x-foo',
properties : {
message: {
type: String,
value: "Hello world!"
}
}
});
</script>
</dom-module>
index.html
<head>
<!-- PolyGit used here as CDN for demo purposes only. In production,
it's recommended to import Polymer and Web Components locally
from Bower. -->
<base href="https://polygit.org/polymer+1.6.0/components/">
<script src="webcomponentsjs/webcomponents-lite.min.js"></script>
<link rel="import" href="polymer/polymer.html">
<link rel="import" href="x-foo.html">
</head>
<body>
<x-foo></x-foo>
</body>
See demo in CodePen