Polymer 1.0 Node.bind() - Can I create a binding via javascript instead of double braces?

筅森魡賤 提交于 2019-12-11 16:30:36

问题


Is there a way in Polymer 1.0 to set up a binding using javascript like Node.bind() did previously?

[Ignore this: Apparently being succinct is not allowed in stackoverflow so I have to write this useless sentence in order to post the question.]


回答1:


Short answer is: NO. Polymer 1.0 currently does not support imperative data-binding.

In 1.0, the data-binding mechanism was completely rewrote, so previous 0.5-ish techniques like Node.bind('content', new PathObserver(obj, 'path.to.value')); or

Polymer.import(["/elements/x-test.html"], function () {
  var el = document.createElement('x-test');
  el.setAttribute('foo', '{{bar}}');
  document.querySelector("#insertion_point").appendChild(el);
});

or html-echo does not work.

More info in this SO question: Binding imperatively

More info in Github: https://github.com/Polymer/polymer/issues/1778



来源:https://stackoverflow.com/questions/31271098/polymer-1-0-node-bind-can-i-create-a-binding-via-javascript-instead-of-doubl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!