Skip to content

Commit bbe7416

Browse files
committed
refactor(localization): Update to use inject method where left over.
1 parent effeed6 commit bbe7416

File tree

3 files changed

+11
-24
lines changed

3 files changed

+11
-24
lines changed

projects/igniteui-angular/core/src/data-operations/pipes.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
import { Pipe, PipeTransform, Inject, LOCALE_ID } from '@angular/core';
2-
import { BaseFormatter, I18N_FORMATTER } from '../core/i18n/formatters/formatter-base';
1+
import { Pipe, PipeTransform, LOCALE_ID, inject } from '@angular/core';
2+
import { I18N_FORMATTER } from '../core/i18n/formatters/formatter-base';
33

44
@Pipe({
55
name: 'date',
66
standalone: true
77
})
88
export class IgxDateFormatterPipe implements PipeTransform {
9-
10-
constructor(
11-
@Inject(I18N_FORMATTER) private i18nFormatter: BaseFormatter,
12-
@Inject(LOCALE_ID) private locale_ID
13-
) { }
9+
private i18nFormatter = inject(I18N_FORMATTER);
10+
private locale_ID = inject(LOCALE_ID);
1411

1512
public transform(value: Date | string | number | null | undefined, format?: string, timezone?: string, locale?: string) {
1613
return this.i18nFormatter.formatDate(value, format, locale ?? this.locale_ID, timezone);
@@ -22,8 +19,7 @@ export class IgxDateFormatterPipe implements PipeTransform {
2219
standalone: true
2320
})
2421
export class IgxNumberFormatterPipe implements PipeTransform {
25-
26-
constructor(@Inject(I18N_FORMATTER) private i18nFormatter: BaseFormatter) { }
22+
private i18nFormatter = inject(I18N_FORMATTER);
2723

2824
public transform(value: number | string | null | undefined, digitsInfo?: string, locale?: string) {
2925
return this.i18nFormatter.formatNumber(value, locale, digitsInfo);
@@ -35,8 +31,7 @@ export class IgxNumberFormatterPipe implements PipeTransform {
3531
standalone: true
3632
})
3733
export class IgxPercentFormatterPipe implements PipeTransform {
38-
39-
constructor(@Inject(I18N_FORMATTER) private i18nFormatter: BaseFormatter) { }
34+
private i18nFormatter = inject(I18N_FORMATTER);
4035

4136
public transform(value: number | string | null | undefined, digitsInfo?: string, locale?: string) {
4237
return this.i18nFormatter.formatPercent(value, locale, digitsInfo);
@@ -48,8 +43,7 @@ export class IgxPercentFormatterPipe implements PipeTransform {
4843
standalone: true
4944
})
5045
export class IgxCurrencyFormatterPipe implements PipeTransform {
51-
52-
constructor(@Inject(I18N_FORMATTER) private i18nFormatter: BaseFormatter) { }
46+
private i18nFormatter = inject(I18N_FORMATTER);
5347

5448
public transform(value: number | string | null | undefined, currencyCode?: string, display?: 'code' | 'symbol' | 'symbol-narrow' | string , digitsInfo?: string, locale?: string) {
5549

projects/igniteui-angular/directives/src/directives/date-time-editor/date-time-editor.directive.spec.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ describe('IgxDateTimeEditor', () => {
2020
describe('Unit tests', () => {
2121
let maskParsingService: jasmine.SpyObj<MaskParsingService>;
2222
let renderer2: jasmine.SpyObj<Renderer2>;
23-
let locale = 'en';
2423
let elementRef: ElementRef;
2524
let inputFormat: string;
2625
let displayFormat: string;
@@ -92,7 +91,6 @@ describe('IgxDateTimeEditor', () => {
9291
it('should set default inputFormat with parts for day, month, year based on locale', () => {
9392
registerLocaleData(localeBg);
9493
registerLocaleData(localeJa);
95-
locale = 'en-US';
9694
inputFormat = undefined;
9795
elementRef = { nativeElement: { value: inputDate } };
9896
initializeDateTimeEditor();
@@ -129,7 +127,6 @@ describe('IgxDateTimeEditor', () => {
129127

130128
it('should resolve to the default locale-based input format in case inputFormat is not set and displayFormat contains non-numeric date/time parts', () => {
131129
registerLocaleData(localeBg);
132-
locale = 'en-US';
133130
displayFormat = undefined;
134131
elementRef = { nativeElement: { value: inputDate } };
135132
initializeDateTimeEditor();

projects/igniteui-angular/grids/core/src/filtering/excel-style/excel-style-date-expression.component.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { ChangeDetectorRef, Component, Inject, Input, ViewChild } from '@angular/core';
1+
import { Component, inject, Input, ViewChild } from '@angular/core';
22
import { IgxExcelStyleDefaultExpressionComponent } from './excel-style-default-expression.component';
33
import { FormsModule } from '@angular/forms';
44
import { IgxSelectComponent, IgxSelectItemComponent } from 'igniteui-angular/select';
55
import { IgxInputDirective, IgxInputGroupComponent, IgxPrefixDirective } from 'igniteui-angular/input-group';
66
import { IgxIconComponent } from 'igniteui-angular/icon';
77
import { IgxDatePickerComponent } from 'igniteui-angular/date-picker';
8-
import { IgxOverlayOutletDirective, IgxPickerClearComponent, IgxPickerToggleComponent, PlatformUtil, BaseFormatter, I18N_FORMATTER } from 'igniteui-angular/core';
8+
import { IgxOverlayOutletDirective, IgxPickerClearComponent, IgxPickerToggleComponent, I18N_FORMATTER } from 'igniteui-angular/core';
99
import { IgxTimePickerComponent } from 'igniteui-angular/time-picker';
1010
import { IgxButtonDirective, IgxDateTimeEditorDirective, IgxIconButtonDirective } from 'igniteui-angular/directives';
1111
import { IgxButtonGroupComponent } from 'igniteui-angular/button-group';
@@ -19,6 +19,8 @@ import { IgxButtonGroupComponent } from 'igniteui-angular/button-group';
1919
imports: [IgxSelectComponent, IgxPrefixDirective, IgxIconComponent, IgxSelectItemComponent, IgxDatePickerComponent, IgxPickerToggleComponent, IgxPickerClearComponent, IgxTimePickerComponent, IgxInputGroupComponent, FormsModule, IgxInputDirective, IgxDateTimeEditorDirective, IgxButtonDirective, IgxButtonGroupComponent, IgxOverlayOutletDirective, IgxIconButtonDirective]
2020
})
2121
export class IgxExcelStyleDateExpressionComponent extends IgxExcelStyleDefaultExpressionComponent {
22+
protected i18nFormatter = inject(I18N_FORMATTER);
23+
2224
@ViewChild('input', { read: IgxInputDirective, static: false })
2325
private input: IgxInputDirective;
2426

@@ -49,10 +51,4 @@ export class IgxExcelStyleDateExpressionComponent extends IgxExcelStyleDefaultEx
4951
public get weekStart(): number {
5052
return this.i18nFormatter.getLocaleFirstDayOfWeek(this.grid.locale);
5153
}
52-
53-
constructor(cdr: ChangeDetectorRef,
54-
@Inject(I18N_FORMATTER) protected i18nFormatter: BaseFormatter,
55-
platform: PlatformUtil) {
56-
super(cdr, platform);
57-
}
5854
}

0 commit comments

Comments
 (0)