Skip to content

Commit

Permalink
fix(datepicker): configurable TitleCasePipe in DatePicker
Browse files Browse the repository at this point in the history
Allow to customize usage of TitleCasePipe in DateInput/DatePicker by injecting it.

closes sbb-design-systems#226
  • Loading branch information
daniel-sc committed Nov 25, 2019
1 parent 8df17ce commit b16756c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,6 @@ export class DateInputDirective<D> 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 = () => {};
Expand Down Expand Up @@ -256,6 +254,7 @@ export class DateInputDirective<D> implements ControlValueAccessor, Validator, O

constructor(
private _elementRef: ElementRef<HTMLInputElement>,
private _titleCasePipe: TitleCasePipe,
@Optional() public dateAdapter: DateAdapter<D>,
@Optional() @Inject(SBB_DATE_FORMATS) private _dateFormats: DateFormats,
@Optional() private _datepicker: DatepickerComponent<D>
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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]
})
Expand Down

0 comments on commit b16756c

Please sign in to comment.