Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(datepicker): input datepicker global config
Closes #3273
- Loading branch information
1 parent
b35f759
commit a9ce83e
Showing
8 changed files
with
120 additions
and
11 deletions.
There are no files selected for viewing
14 changes: 12 additions & 2 deletions
14
demo/src/app/components/datepicker/demos/config/datepicker-config.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
<p>This datepicker uses customized default values.</p> | ||
<p>This datepicker input uses customized default values.</p> | ||
|
||
<ngb-datepicker [(ngModel)]="model"></ngb-datepicker> | ||
<form class="form-inline"> | ||
<div class="form-group"> | ||
<div class="input-group"> | ||
<input class="form-control" placeholder="yyyy-mm-dd" | ||
name="dp" [(ngModel)]="model" ngbDatepicker #d="ngbDatepicker"> | ||
<div class="input-group-append"> | ||
<button class="btn btn-outline-secondary calendar" (click)="d.toggle()" type="button"></button> | ||
</div> | ||
</div> | ||
</div> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {NgbInputDatepickerConfig} from './datepicker-input-config'; | ||
|
||
describe('NgbInputDatepickerConfig', () => { | ||
it('should have sensible default values', () => { | ||
const config = new NgbInputDatepickerConfig(); | ||
|
||
expect(config.autoClose).toBe(true); | ||
expect(config.container).toBeUndefined(); | ||
expect(config.positionTarget).toBeUndefined(); | ||
expect(config.placement).toEqual(['bottom-left', 'bottom-right', 'top-left', 'top-right']); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import {Injectable} from '@angular/core'; | ||
|
||
import {PlacementArray} from '../util/positioning'; | ||
|
||
/** | ||
* A configuration service for the [`NgbDatepickerInput`](#/components/datepicker/api#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 datepicker inputs used in the application. | ||
*/ | ||
@Injectable({providedIn: 'root'}) | ||
export class NgbInputDatepickerConfig { | ||
autoClose: boolean | 'inside' | 'outside' = true; | ||
container: null | 'body'; | ||
positionTarget: string | HTMLElement; | ||
placement: PlacementArray = ['bottom-left', 'bottom-right', 'top-left', 'top-right']; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters