Search code examples
datepickerngx-bootstrap

Angular 6 and bootstrap 4: date picker current date selection


I have a form which contain a date picker and it works as expected except the current date is not selected.

When I open the calendar it shows as follows

enter image description here

But I need the current date focused when ever I open the .date picker as follows

enter image description here


Solution

  • Add customTodayClass to the bsConfig and use css to change the background color of the date.

    <input type="text"
        placeholder="Datepicker"
        class="form-control"
        bsDatepicker
        [bsConfig]="{'customTodayClass': 'today'}"
     />
    

    Add CSS for today class like below.

    .today{
      background-color: #DCDCDC
    }