angularng-bootstrapngb-datepicker

How can I start the calendar week in ng bootstrap Datepicker from Sunday instead of Monday?


I want to set the ngbDatepicker to begin the week on Sunday instead of the default day Monday.

I am trying to use weekStartsOn="0" but it has no effect. This is my html code

<input ngbDatepicker #d="ngbDatepicker" class="form-control" [minDate]="minDate" [maxDate]="maxDate" [markDisabled]="isDisabled" weekStartsOn="0">


Solution

  • You can achieve that by passing in 7 to the firstDayOfWeek input property.

    E.g.

    <input class="form-control" placeholder="yyyy-mm-dd" name="dp" 
        [(ngModel)]="model" ngbDatepicker #d="ngbDatepicker" firstDayOfWeek="7">
    

    enter image description here

    If you need to further configure/tweak your datepicker, you can take a look at ng-bootstrap datepicker component's full API here: Ng-Bootstrap Datepicker API.

    Here's a forked stackblitz to show that it works: Stackblitz Example.