Following code doesnt work because fromView() is called for each updates, resulting in wrong date construction. What the best solution to use bi-directional filters on dates with aurelia ?
<input type=text" value.bind="date | dateFormat: 'DD/MM/YY'"></input>
import moment from 'moment';
export class DateFormatValueConverter {
toView(value, format) {
return moment(value).format(format);
}
fromView(str, format){
return moment(str, format);
}
}
答案 0 :(得分:3)
这是一个老问题,但是如果有其他人在想,要改变绑定以重新评估模糊使用:
<pre>
<input type=text" value.bind="date | dateFormat: 'DD/MM/YY' &
updateTrigger:'blur'"></input>;
</pre>