问题描述
我想将 ngbDatepicker 设置为从星期日开始一周,而不是默认的星期一.
I want to set the ngbDatepicker to begin the week on Sunday instead of the default day Monday.
我正在尝试使用 weekStartsOn="0" 但它没有效果.这是我的html代码
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">
推荐答案
您可以通过将 7
传递给 firstDayOfWeek
输入属性来实现这一点.
You can achieve that by passing in 7
to the firstDayOfWeek
input property.
例如
<input class="form-control" placeholder="yyyy-mm-dd" name="dp"
[(ngModel)]="model" ngbDatepicker #d="ngbDatepicker" firstDayOfWeek="7">
如果您需要进一步配置/调整您的日期选择器,您可以在此处查看 ng-bootstrap
日期选择器组件的完整 API:Ng-Bootstrap Datepicker API.
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.
这是一个分叉的 stackblitz 来证明它有效:Stackblitz 示例.
Here's a forked stackblitz to show that it works: Stackblitz Example.
这篇关于如何从星期日而不是星期一在 ng bootstrap Datepicker 中开始日历周?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!