I'm trying to configure the ngbBootstrap datepicker to use Sunday as the first day of the week. Seems like this should be super simple according to the docs. I am using NgbBootstrap v1.1.2, but the documentation in code is the same as the current docs:
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;
}
//...
}
Any ideas why it's still set to Monday?
Update
Seems to work if I override the service defaults:
{
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 };
}
}