简体   繁体   English

是否可以渲染列表 <Element> 在Polymer.dart中?

[英]Is it possible to render a List<Element> in Polymer.dart?

Given a List<Element> elements , is it possible to render the elements in the template, like this? 给定List<Element> elements ,是否可以像这样渲染模板中的元素?

<template repeat="{{element in elements}}">
    {{element.SOMETHING}}
</template>

I'd want it to observe the list too, so that it would add and remove elements as the list changes. 我希望它也观察列表,以便它在列表更改时添加和删除元素。

Update 更新

A ready-to-use element for Dart Polymer 1.0 is bwu-bind-html Dart Polymer 1.0的现成元素是bwu-bind-html


{{}} can't include HTML. {{}}不能包含HTML。

You can use something like the <safe-html> tag (see answer to HTML Tags Within Internationalized Strings In Polymer.dart ) 您可以使用<safe-html>标记之类的内容(请参见Polymer.dart中国际化字符串中HTML标记的答案)

<template repeat="{{element in elements}}">
    <safe-html model="{{element.SOMETHING}}"></safe-html>
</template>

but I guess you have to change the <self-html> implementation so that it replaces itself with the content of model instead of adding model to it's content, because ul / ol can't contain <self-html> 但我想您必须更改<self-html>实现,以便它用model的内容替换自身,而不是在其内容中添加model ,因为ul / ol不能包含<self-html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM