ngx-bootstrap icon indicating copy to clipboard operation
ngx-bootstrap copied to clipboard

Is there a way to show a message just before datepicker shown?

Open adurmus opened this issue 3 years ago • 1 comments

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?

adurmus avatar Sep 02 '22 15:09 adurmus

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 ''.

adurmus avatar Sep 02 '22 17:09 adurmus