core-list-dart: How access variable (@observable) outside data attribute

回眸只為那壹抹淺笑 提交于 2019-12-11 03:03:39

问题


I'm trying to apply a filter through a variable (asDateTime) for a given column to the core-list-dart.

This variable is outside of the content data attribute (model). When I access this variable, an error is throws.

See the code:

* 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 *

Exception: Uncaught Error: Error evaluating expression '(model.dataVencimento | asDateTime)': Class '_ListModel' has no instance getter 'asDateTime'.

NoSuchMethodError: method not found: 'asDateTime' Receiver: Instance of '_ListModel' Arguments: []

Is there any way to access a variable outside the core-list-dart?

Thanks!

来源:https://stackoverflow.com/questions/28544403/core-list-dart-how-access-variable-observable-outside-data-attribute

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!