import ngModule from '../../module'; import Field from '../field'; class DatePicker extends Field { constructor($element, $scope, $compile) { super($element, $scope, $compile); this.input = $compile(``)($scope)[0]; this.input.addEventListener('change', () => this.onValueUpdate()); } onValueUpdate() { let date = null; let value = this.input.value; if (value) { date = new Date(value); if (this.field) { let orgDate = this.field instanceof Date ? this.field : new Date(this.field); date.setHours( orgDate.getHours(), orgDate.getMinutes(), orgDate.getSeconds(), orgDate.getMilliseconds() ); } } super.field = date; this.$.$applyAsync(); } get field() { return super.field; } set field(value) { super.field = value; this.input.value = this.$filter('date')(value, 'yyyy-MM-dd'); } } DatePicker.$inject = ['$element', '$scope', '$compile']; ngModule.vnComponent('vnDatePicker', { controller: DatePicker, bindings: { options: '