Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(datepicker): fix config example #4620

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component } from '@angular/core';
import {
NgbCalendar,
NgbDate,
NgbDatepickerConfig,
NgbDatepickerModule,
NgbDateStruct,
NgbInputDatepickerConfig,
Expand All @@ -13,12 +14,12 @@ import { FormsModule } from '@angular/forms';
standalone: true,
imports: [NgbDatepickerModule, FormsModule],
templateUrl: './datepicker-config.html',
providers: [NgbInputDatepickerConfig], // add config to the component providers
providers: [NgbInputDatepickerConfig, NgbDatepickerConfig], // add config to the component providers
})
export class NgbdDatepickerConfig {
model: NgbDateStruct;

constructor(config: NgbInputDatepickerConfig, calendar: NgbCalendar) {
constructor(inputConfig: NgbInputDatepickerConfig, config: NgbDatepickerConfig, calendar: NgbCalendar) {
// customize default values of datepickers used by this component tree
config.minDate = { year: 1900, month: 1, day: 1 };
config.maxDate = { year: 2099, month: 12, day: 31 };
Expand All @@ -30,9 +31,9 @@ export class NgbdDatepickerConfig {
config.markDisabled = (date: NgbDate) => calendar.getWeekday(date) >= 6;

// setting datepicker popup to close only on click outside
config.autoClose = 'outside';
inputConfig.autoClose = 'outside';

// setting datepicker popup to open above the input
config.placement = ['top-start', 'top-end'];
inputConfig.placement = ['top-start', 'top-end'];
}
}