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

2019-07-21 00:51发布

问题:

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!