我正在使用<core-list-dart>
我的 Polymer Dart 应用程序中的元素:
<core-list-dart data="{{data}}">
<template>
<span>{{name}}</span>
</template>
</core-list-dart>
Data 是 Foo 的数组,其中 Foo 是:
class Foo {
String name;
...
}
模板中是否可以引用 Foo 实例而不是他的字段?
就像是:
<core-list-dart data="{{data}}">
<template>
<foo-element foo="{{ITEM}}"></foo-element>
</template>
</core-list-dart>
从版本0.4.0core_elements 模型公开为model
模板中的变量。
旧回复:
要绑定项目,您可以使用{{}}
@Günter Zöchbauer 答案中解释的注释:
<foo-element foo="{{}}"></foo-element>
问题在于数组中的元素由 ListModel 类包装。 “真实”元素不可访问(也许可以修改库以提供这种可能性)。
解决方法是向模型对象 (Foo) 添加 getter,如下所示:
class Foo {
String name;
Foo get self => this;
...
}
所以在模板中你可以这样做:
<foo-element foo="{{self}}"></foo-element>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)