Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8"/>
  <meta name="viewport" content="width=device-width"/>
  <title>JS Bin</title>
  <base href="http://polygit.org/polymer+:master/components/"/>
  <link href="polymer/polymer-element.html" rel="import"/>
  <link href="polymer/lib/mixins/template-stamp.html" rel="import"/>
  
</head>
<body>
  
<dom-module id="my-parent">
  <template>
    <my-child>
      <template>
        <div>Child's data property: [[data]]</div>
      </template>
    </my-child>
  </template>
  <script>
    class MyParent extends Polymer.Element {
      static get is() { return 'my-parent'; }
    }
    window.customElements.define(MyParent.is, MyParent);
  </script>
</dom-module>
<dom-module id="my-child">
  <template>
    <header>Header</header>
    <div id="content"></div>
    <footer>Footer</footer>
    <input type="text" value="{{data::input}}" />
  </template>
  <script>
    class MyChild extends Polymer.TemplateStamp(Polymer.Element) {
      static get is() { return 'my-child'; }
      static get properties() {
        return {
          data: {
            type: String,
            value: 'Hello, World!'
          },
        };
      }
      
      connectedCallback() {
        super.connectedCallback();
        
        var template = this.querySelector('template');
        this.__instance = this._stampTemplate(template);
        this.$.content.appendChild(this.__instance);
      }
    }
    window.customElements.define(MyChild.is, MyChild);
  </script>
</dom-module>
  
<my-parent></my-parent>
  
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers