From b16756cd7dfdbc4668165abd7f362807bad9f277 Mon Sep 17 00:00:00 2001 From: "Schreiber Daniel (IT-SWE-CC3-TTF)" Date: Mon, 25 Nov 2019 10:04:51 +0100 Subject: [PATCH] fix(datepicker): configurable TitleCasePipe in DatePicker Allow to customize usage of TitleCasePipe in DateInput/DatePicker by injecting it. closes #226 --- .../datepicker/src/date-input/date-input.directive.ts | 3 +-- .../angular-public/datepicker/src/datepicker.module.ts | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/sbb-esta/angular-public/datepicker/src/date-input/date-input.directive.ts b/projects/sbb-esta/angular-public/datepicker/src/date-input/date-input.directive.ts index 02774c6713..aa52dcc148 100644 --- a/projects/sbb-esta/angular-public/datepicker/src/date-input/date-input.directive.ts +++ b/projects/sbb-esta/angular-public/datepicker/src/date-input/date-input.directive.ts @@ -206,8 +206,6 @@ export class DateInputDirective implements ControlValueAccessor, Validator, O /** Whether the last value set on the input was valid. */ private _lastValueValid = false; - private _titleCasePipe = new TitleCasePipe(); - onTouched = () => {}; private _cvaOnChange: (value: any) => void = () => {}; @@ -256,6 +254,7 @@ export class DateInputDirective implements ControlValueAccessor, Validator, O constructor( private _elementRef: ElementRef, + private _titleCasePipe: TitleCasePipe, @Optional() public dateAdapter: DateAdapter, @Optional() @Inject(SBB_DATE_FORMATS) private _dateFormats: DateFormats, @Optional() private _datepicker: DatepickerComponent diff --git a/projects/sbb-esta/angular-public/datepicker/src/datepicker.module.ts b/projects/sbb-esta/angular-public/datepicker/src/datepicker.module.ts index 98a28795d9..eb01f98034 100644 --- a/projects/sbb-esta/angular-public/datepicker/src/datepicker.module.ts +++ b/projects/sbb-esta/angular-public/datepicker/src/datepicker.module.ts @@ -1,7 +1,7 @@ import { A11yModule } from '@angular/cdk/a11y'; import { OverlayModule } from '@angular/cdk/overlay'; import { PortalModule } from '@angular/cdk/portal'; -import { CommonModule } from '@angular/common'; +import { CommonModule, TitleCasePipe } from '@angular/common'; import { NgModule } from '@angular/core'; import { DATE_PIPE_DATE_FORMATS, @@ -59,7 +59,8 @@ import { MonthViewComponent } from './month-view/month-view.component'; providers: [ SBB_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER, { provide: DateAdapter, useClass: NativeDateAdapter }, - { provide: SBB_DATE_FORMATS, useValue: DATE_PIPE_DATE_FORMATS } + { provide: SBB_DATE_FORMATS, useValue: DATE_PIPE_DATE_FORMATS }, + { provide: TitleCasePipe, useClass: TitleCasePipe } ], entryComponents: [DatepickerContentComponent, CalendarHeaderComponent] })