Skip to content

Commit

Permalink
fix(datepicker): fix daterangepicker crash on empty value
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaSurmay committed Sep 15, 2017
1 parent 6b7a8c4 commit a30a283
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<br>

<pre>{{bsRangeValue}}</pre>
<pre>{{ bsRangeValue[0] | date:'yMd'}} - {{ bsRangeValue[1] | date:'yMd'}}</pre>
<pre *ngIf="bsRangeValue">{{ bsRangeValue[0] | date:'yMd'}} - {{ bsRangeValue[1] | date:'yMd'}}</pre>
<input #drp="bsDaterangepicker" bsDaterangepicker [(bsValue)]="bsRangeValue">
<input bsDaterangepicker [(ngModel)]="bsRangeValue">
<input [(ngModel)]="bsRangeValue">
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"demo.serve": "run-s build link demo.docs demo.build docs.archive lite-server",
"demo.serve-fast": "run-s build link demo.docs demo.build-fast docs.archive lite-server",
"demo.gh-pages": "run-s build demo.docs demo.build docs.archive demo.deploy",
"demo.build": "ng build -prod --aot --build-optimizer --preserve-symlinks -nc",
"demo.build": "ng build -prod --aot --preserve-symlinks -nc",
"demo.build-fast": "ng build",
"demo.deploy": "gh-pages -d gh-pages",
"demo-beta-deploy": "gh-pages -d gh-pages -r git@github.com:valorkin/ngx-bootstrap.git -b gh-pages",
Expand Down
7 changes: 4 additions & 3 deletions src/datepicker/bs-daterangepicker-input.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ export class BsDaterangepickerInputDirective
v[0],
this._picker._config.rangeInputFormat,
this._picker._config.locale
);
) || '';
const end = formatDate(
v[1],
this._picker._config.rangeInputFormat,
this._picker._config.locale
);
range = start + this._picker._config.rangeSeparator + end;
) || '';
range = (start && end) ? start + this._picker._config.rangeSeparator + end : '';
}
this._renderer.setProperty(this._elRef.nativeElement, 'value', range);
this._onChange(v);
Expand All @@ -58,6 +58,7 @@ export class BsDaterangepickerInputDirective
writeValue(value: Date[] | string) {
if (!value) {
this._picker.bsValue = null;
return;
}

const _locale = getLocale(this._picker._config.locale);
Expand Down

0 comments on commit a30a283

Please sign in to comment.