Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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">

like image 949
Jake Neumann Avatar asked Nov 21 '19 08:11

Jake Neumann


1 Answers

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.

like image 168
terahertz Avatar answered Sep 21 '22 13:09

terahertz