ngx-bootstrap
ngx-bootstrap copied to clipboard
Is there a way to show a message just before datepicker shown?
I'd like to display a message to user when input field is clicked (toaster message) and when the user sees and closes the message then open the datepicker. beforeShown event?
Is this achievable with existing events?
Figured out a hack
.html
<input type="text" #datePicker="bsDatepicker" [triggers]="''" placeholder="Datepicker" class="form-control" (mouseup)="onShownDatePicker($event)" bsDatepicker>
.component.ts
@ViewChild('datePicker') datePicker: BsDatepickerDirective;
onShownDatePicker(): void {
//show your message here and in the event of closing your message fire to display datepicker.
this.messageService.showInfo(
'your message before displaying date picker',
'Important',
{ didClose: () => this.datePicker.show() }
);
}
You must set the triggers input to ''. Otherwise it will display the date picker.
you call (mouseup) event to show the message. onShown won't be fired as triggers is set to ''.