gpt4 book ai didi

angular - ngbBootstrap DatePicker 配置集 firstDayOfWeek

转载 作者:行者123 更新时间:2023-12-05 03:04:14 31 4
gpt4 key购买 nike

我正在尝试将 ngbBootstrap 日期选择器配置为使用星期日作为一周的第一天。根据 docs 看来这应该 super 简单.我使用的是 NgbBootstrap v1.1.2,但代码中的文档与当前文档相同:

Configuration service for the NgbDatepicker component. You can inject this service, typically in your root component, and customize the values of its properties in order to provide default values for all the datepickers used in the application.

import { NgbDatepickerConfig } from '@ng-bootstrap/ng-bootstrap';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
//...

constructor(
private ngbDatepickerConfig: NgbDatepickerConfig
) {
ngbDatepickerConfig.firstDayOfWeek = 7;
}

//...
}

知道为什么仍设置为星期一吗?

更新

如果我覆盖服务默认值,似乎可以工作:

{
provide: NgbDatepickerConfig,
useClass: class Test {
dayTemplate: TemplateRef<DayTemplateContext>;
dayTemplateData: (date: NgbDateStruct, current: { year: number, month: number }) => any;
footerTemplate: TemplateRef<any>;
displayMonths = 1;
firstDayOfWeek = 7;
markDisabled: (date: NgbDateStruct, current: { year: number, month: number }) => boolean;
minDate: NgbDateStruct;
maxDate: NgbDateStruct;
navigation: 'select' | 'arrows' | 'none' = 'select';
outsideDays: 'visible' | 'collapsed' | 'hidden' = 'visible';
showWeekdays = true;
showWeekNumbers = false;
startDate: { year: number, month: number };
}
}

最佳答案

不知道为什么,但是当所有子组件都延迟加载时,它对根组件不起作用。我将它应用于一个公共(public)组件,该组件用作所有功能模块路由子项的父级,并且它按预期在整个应用程序中工作。

关于angular - ngbBootstrap DatePicker 配置集 firstDayOfWeek,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53126700/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com