1

In the Dart Web UI package, it is possible to create bindings using the {{}} or bind-value syntax. Is this also possible, when DOM elements are created in code?

Something like

new Element.html('<div>Value: {{str}}</div>');

and

new Element.html('<input type="text" bind-value="str">');

binding an event to str, without manually piecing the strings together?


Note: this question was asked earlier today, but was deleted before it was answered, but I wanted to know the answer, so I'm reposting it.

4

1 回答 1

2

快速回答,没有。

绑定需要由dwc转换器处理,转换器将 Web 组件和 MDV 代码转换为“vanilla” Dart 和 HTML(适合编译为“vanilla” JavaScript)。

通常,您应该使用<template>标签来实例化新元素。

另一种方法是将这些文本位包装在自定义元素中,您可以使用它进行转换dwc和手动实例化。

于 2013-04-22T21:59:30.753 回答