core-list-dart:如何访问变量(@observable)外部数据属性

时间:2015-02-16 15:09:00

标签: dart polymer dart-polymer core-elements

我试图通过给定列的变量(asDateTime)将过滤器应用于core-list-dart。

此变量位于内容数据属性(模型)之外。当我访问此变量时,会抛出错误。

参见代码:

* dominio.dart *

class ContaPagar {  
  ...  
  List<ContaPagarParcela> contaPagarParcelas;
}

class ContaPagarParcela {
  ...
  DateTime dataVencimento; 
}

* filter.dart *

class StringToDateTime extends Transformer<String, DateTime> {
  String forward(DateTime dateTime) {
    String str = dateTime.toString();
    return str.substring(0, str.lastIndexOf(' '));
  }

  DateTime reverse(String str) {
    try {
      return DateTime.parse(str);
    } on Exception {
      return null;
    }
  }
}

* webcp.dart *

@observable ContaPagar contaPagar;
@observable StringToDateTime asDateTime = new StringToDateTime();

ApisContaPagar.created() : super.created() {
    contaPagar.contaPagarParcelas = toObservable(new List()..add(new ContaPagarParcela()));   
}

* webcp.html *

<core-list-dart id="core_list_dart_parcela" data="{{contaPagar.contaPagarParcelas}}">
  <template>
    <div class="itemParcela" horizontal layout>     
      <div>
         <input is="core-input" type="date" value="{{model.dataVencimento | asDateTime}}" required>
      </div>
     </div>
   </template>
</core-list-dart>

* Erro *

  

例外:未捕获错误:评估表达式时出错&#39;(model.dataVencimento | asDateTime)&#39;:Class&#39; _ListModel&#39;没有实例getter&#39; asDateTime&#39;。

     

NoSuchMethodError:找不到方法:&#39; asDateTime&#39;   接收者:&#39; _ListModel&#39;的实例   参数:[]

有没有办法访问core-list-dart之外的变量?

谢谢!

0 个答案:

没有答案