I'm working with ngx-bootstrap's rangeDatePicker, and I'm trying to go to the previous month as soon as the rangeDatePicker is shown, using it inside my handler function, which is called with the onShown event.
Code is the following: in the HTML
<input id="input-range-dates" type="text" class="form-control" bsDaterangepicker #drp="bsDaterangepicker" [bsConfig]="bsConfig"
[(ngModel)]="bsRangeValue" (ngModelChange)="onChanges($event, drp)" [maxDate]="maxDate" placement="bottom"
(onShown)="handler('onShown')" (onHidden)="handler('onHidden')" readonly/>
As you can see, there are lots of properties, but the only one regarding this question is the
(onShown)="handler('onShown')"
in the JS
handler(value: string): void {
if ('onShown' === value) {
[].slice.call(document.getElementsByClassName('previous')).filter(element =>
element.innerText === '‹')[0].click(); // previous Month
}
}
However if I debug it on chrome, I can see that the calendar with the button has not appeared yet, and the click action does not change the month.
Somebody can help with this? I'm stuck..