If you decide to split your elements into your own files, you can follow this Plunker ( nazerke ) example , showing two-way data binding if one component is observing another property.
code
index.html
<!DOCTYPE html> <html lang="en"> <head> <script src="http://www.polymer-project.org/1.0/samples/components/webcomponentsjs/webcomponents-lite.min.js"></script> <link rel="import" href="parent-element.html"> <link rel="import" href="first-child.html"> <link rel="import" href="second-child.html"> </head> <body> <parent-element></parent-element> </body> </html>
parent-element.html
<link rel="import" href="http://www.polymer-project.org/1.0/samples/components/polymer/polymer.html"> <dom-module id="parent-element"> <template> <first-child prop={{value}}></first-child> <second-child feat1={{prop}}></second-child> In parent-element <h1>{{value}}</h1> </template> <script> Polymer({ is: "parent-element", properties: { value: { type: String } }, valueChanged: function() { console.log("value changed"); } }); </script> </dom-module>
first child.html
<link rel="import" href="http://www.polymer-project.org/1.0/samples/components/polymer/polymer.html"> <dom-module id="first-child"> <template> <p>first element.</p> <h2>{{prop}}</h2> </template> <script> Polymer({ is: "first-child", properties: { prop: { type: String, notify: true } }, ready: function() { this.prop = "property"; } }); </script> </dom-module>
second child.html
<link rel="import" href="http://www.polymer-project.org/1.0/samples/components/polymer/polymer.html"> <dom-module id="second-child"> <template> <p>Second element.</p> <h2>{{feat1}}</h2> </template> <script> Polymer({ is: "second-child", properties: { feat1: { type: String, notify: true, value: "initial value" } }, ready: function() { this.addEventListener("feat1-changed", this.myAct); }, myAct: function() { console.log("feat1-changed ", this.feat1); } }); </script> </dom-module>
source share