Skip to content

Commit

Permalink
feat(clear): when setting value to falsy, datepicker will clear, and …
Browse files Browse the repository at this point in the history
…added demo

#11
  • Loading branch information
fetrarij committed Nov 23, 2018
1 parent f0f4cce commit 18559a7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions demo/src/app/simple/simple.component.html
Expand Up @@ -9,6 +9,7 @@
<div class="col s6 right-align">
<br/>
<button type="button" class="ngx-daterangepicker-action waves-effect waves-light btn" (click)="open($event)">open from a button</button>
<button type="button" *ngIf="selected && selected.startDate" class="ngx-daterangepicker-action waves-effect waves-light btn red" (click)="clear($event)">Clear</button>
</div>
</div>
<div class="row">
Expand Down
4 changes: 4 additions & 0 deletions demo/src/app/simple/simple.component.ts
Expand Up @@ -34,4 +34,8 @@ export class SimpleComponent implements OnInit {
open(e) {
this.pickerDirective.open(e);
}
clear(e) {
// this.picker.clear(); // we can do
this.selected = null; // now we can do
}
}
2 changes: 1 addition & 1 deletion src/daterangepicker/daterangepicker.directive.ts
Expand Up @@ -236,7 +236,7 @@ export class DaterangepickerDirective implements OnInit, OnChanges, DoCheck {
this._el.nativeElement.value = this.picker.chosenLabel;
}
} else {
//
this.picker.clear();
}
}
/**
Expand Down

0 comments on commit 18559a7

Please sign in to comment.