2015-08-15 44 views
1
<template is="dom-bind" id="app"> 
    <div>{{title}}</div> 
    <my-element></my-element> 
</template> 

我可以在my-element強制自動綁定模板重繪嗎?使用Polymer更改自動綁定模板元素

我能得到的模板,但改變它不會觸發重繪:

var app = document.querySelector('#app'); 
app.title = 'Zaphod'; 

回答

1

您的代碼應該工作,除設置title需要等到聚合物準備(即元素已被註冊並準備與之互動)。

var app = document.querySelector('#app'); 

document.addEventListener("WebComponentsReady", function() { 
    app.title = 'Zaphod'; 
}); 
+1

你說得對,我的代碼工作。我的問題是在其他地方,你的答案幫助我達到那裏。感謝名單 –

相關問題