Polymer 1.0 Node.bind() - Can I create a binding v

2019-08-19 02:29发布

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条回答
贪生不怕死
2楼-- · 2019-08-19 02:50

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

查看更多
登录 后发表回答