编辑
我用我刚刚尝试过的示例更新了代码。
我使用 DartEditor 开发通道和 Polymer 0.10.0-pre.12
EDIT END
我没有尝试该代码,但我认为它应该可以工作。
你需要更多的 Dart/HTML 样板来制作一个工作的 Polymer 元素。
请参阅https://www.dartlang.org/polymer-dart/ 以开始使用。
在 Polymer 元素中,您需要一个字段,该字段包含一个包含每行值的集合。
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Sample app</title>
<!-- import the test-element -->
<link rel="import" href="packages/polymer/polymer.html">
<link rel="import" href="test_element.html">
</head>
<body>
<h1>TestPolymer</h1>
<p>Sort observable</p>
<test-element></test-element>
</body>
</html>
test_element.html
<polymer-element name="test-element">
<template>
<style>
tr.foo {
background-color: #00ff00;
}
</style>
<table>
<tr template repeat="{{row in rows}}" class="{{ {'foo': row.contains('Approved')} }}">
<td template repeat="{{cell in row}}">{{cell}}</td>
</tr>
</table>
</template>
<script type="application/dart" src="test_element.dart"></script>
</polymer-element>
test_element.dart
library test_element;
import 'dart:async';
import 'package:polymer/polymer.dart';
@CustomTag('test-element')
class PeopleElement extends PolymerElement {
List<List<String>> rows = toObservable( // toObservable allows to update the HTML itself when the list content changes
[
['Row1-cell1', 'Row1-cell1', 'Row1-cell3', 'Approved'],
['Row2-cell1', 'Approved', 'Row2-cell3', 'Row2-cell4'],
['Approved', 'Row3-cell2', 'Row3-cell3', 'Row3-cell4'],
['Row4-cell1', 'Row4-cell2', 'Row4-cell3', 'Row4-cell4']
]);
PeopleElement.created() : super.created() {
print('PeopleElement');
}
}