Skip to content

Commit

Permalink
fix(input): update input element for model initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
fetrarij committed Jun 11, 2018
1 parent 03e9ee4 commit 95405fc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Component, OnInit } from '@angular/core';
import * as moment from 'moment';

@Component({
selector: 'single-datepicker',
templateUrl: './single-datepicker.component.html',
styleUrls: ['./single-datepicker.component.scss']
})
export class SingleDatepickerComponent implements OnInit {
selected;
selected = moment();
constructor() { }

ngOnInit() {
Expand Down
5 changes: 5 additions & 0 deletions src/daterangepicker/daterangepicker.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export class DaterangepickerDirective implements OnInit, OnChanges, DoCheck {
@Output('change') onChange: EventEmitter<Object> = new EventEmitter();
ngOnInit() {
this.picker.choosedDate.asObservable().subscribe((change: any) => {
console.log('change', change);
if (change) {
const value = {};
value[this._startKey] = change.startDate;
Expand Down Expand Up @@ -185,6 +186,10 @@ export class DaterangepickerDirective implements OnInit, OnChanges, DoCheck {
if (val[this._endKey]) {
this.picker.setEndDate(val[this._endKey])
}
this.picker.calculateChosenLabel();
if (this.picker.chosenLabel) {
this._el.nativeElement.value = this.picker.chosenLabel;
}
} else {
//
}
Expand Down

0 comments on commit 95405fc

Please sign in to comment.