试图将表格呈现为聚合物元素
<table>
<thead>
<tr>
<th template repeat='{{ column in columns}}'>
{{column.displayName}}
</th>
</tr>
</thead>
<tbody>
<tr template repeat='{{ row in data}}'>
<td template repeat='{{ column in columns}}'>
{{row[column.name]}}
</td>
</tr>
</tbody>
</table>
以下表达式似乎不符合我的预期
{{row[column.name]}}
column.name是我要在行对象中访问的属性名称,但是它为所有属性提供了以下异常
NoSuchMethodError: method not found: '[]'
Receiver: Instance of 'Product'
Arguments: ["id"]
这是通过名称访问属性的正确方法吗?
我的行模型看起来像这样
class Product extends Observable{
int id;
String name;
String category;
}
我不喜欢的一项工作是在行类中重载[]
operator [](String fieldName){
var im = reflect(this);
return im.getField(new Symbol(fieldName)).reflectee;
}
如果“行”是地图,这应该可以工作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句