2015-10-15 76 views
1

我有這樣簡單的子元素:聚合物1.0雙向數據與父元件結合

<dom-module id="child-element"> 
    <template> 
     <button on-click="holaClick">Hola local</button> 
     <button on-click="darNombre">Hola otro element</button> 
     <input is="iron-input" bind-value="{{pp}}" 
      placeholder="Your name here..."> 
    </template> 
    <script> 
     Polymer({ 
      is: "child-element", 
      properties: { 
       pp: { 
        //Boolean, Date, Number, String, Array or Object 
        type: String, 
        value: "Valor por defecto de la property" 
       } 
      }, 
      holaClick:function(){ 
       alert("AA: "+this.pp); 
      } 

     }); 
    </script> 
</dom-module> 

我有這樣的父元素:

<?= $this->element('Polymer/test-element'); ?> 
<dom-module id="proto-element"> 
    <template> 

     <!-- scoped CSS for this element --> 
     <style> 
      p { 
       color: red; 
      } 
     </style> 
     <div> 
      <!-- any children are rendered here --> 
      <content> 
       <p>hola3</p> 
       <p2>Este es dinamico: <b>{{myvariable}}</b></p2><br> 
       <p2>Esta es una property: <span>{{myproperty}}</span></p2><br> 
       <p2>Esta es una property que cambie desde el html: <b>{{myproperty2}}</b></p2><br> 
       <p2>Esta es una property que esta bindeada al iron-input: <b>{{myproperty3}}</b></p2><br> 
       <input is="iron-input" bind-value="{{myproperty3}}" 
        placeholder="Your name here..."> 
      </content> 
     </div> 
     <test-element pp="{{myproperty3}}"></test-element> 
    </template> 
    <script> 
     // register a new element called proto-element 
     Polymer({ 
      is: "proto-element", 
      properties: { 
       myproperty: { 
        //Boolean, Date, Number, String, Array or Object 
        type: String, 
        value: "Valor por defecto de la property" 
       }, 
       myproperty2:String, 
       myproperty3:{ 
        //Boolean, Date, Number, String, Array or Object 
        type: String, 
        value: "Valor por defecto de la property 3" 
       } 
      }, 
      ready: function() { 
       this.myvariable = "soy un atributo del elemento!" 
      }, 
      darNombre: function(){ 
       alert("BB"); 
      } 
     }); 
    </script> 
</dom-module> 

當我改變父元素的鐵輸入該綁定工作正常。但是,當我更改子元素的鐵輸入時,父項不會更新。我該如何做這項工作?

謝謝

+0

嘗試設置'通知:TRUE'在你的屬性 – Alan

+0

OMG這麼簡單!謝謝 – Alejandro

回答