在模板重复中调用函数

时间:2016-03-24 11:12:01

标签: binding dart polymer

需要更新看起来像这样的表:

<template is="dom-repeat" items="{{mainList}}" index-as='mainListIndex'>
 <template is="dom-repeat" items="{{mainList}}" index-as='secondListIndex'>
  {{getValueFromListOfLists(mainListIndex, secondListIndex)}}
 </template>
</template>

当mainList a发生变化时,函数getValueFromListOfLists不会再次调用。

@PolymerRegister('matrix-component')
class MatrixComponent extends PolymerElement {

  @Property(reflectToAttribute: true)
  List<List<Map>>  matrix;

  @Property(reflectToAttribute: true)
  List mainList;

  MatrixComponent.created() : super.created();

  @reflctable
  getValueFromListOfLists(firstIndex, secondIndex){
    return matrix[statusFromIndex][statusToIndex]['info'];
  }
}

我如何更新?

1 个答案:

答案 0 :(得分:3)

如果要确保在mainList更新时调用该函数,则必须将其作为参数传递给函数(docs on dependent properties)。

{{getValueFromListOfLists(mainListIndex, secondListIndex, mainList.*)}}
相关问题