Skip to content

Angular - Migration to the inject function #23231

Open
0 of 1 issue completed
Open
Task
0 of 1 issue completed
@sumeyyeKurtulus

Description

@sumeyyeKurtulus

Description

We need to refactor the following constructor to use the new inject() function API instead of relying on Angular's traditional constructor injection:

//npm/ng-packs/packages/core/src/lib/pipes/short-date.pipe.ts
constructor(
  private configStateService: ConfigStateService,
  @Inject(LOCALE_ID) locale: string,
  @Inject(DATE_PIPE_DEFAULT_TIMEZONE) @Optional() defaultTimezone?: string | null,
) {
  super(locale, defaultTimezone);
}

Update the constructor to use the inject() function for all dependencies, following current Angular best practices. This will modernize the code and align it with the latest DI standards introduced in Angular 14+.

You can use Angular's migration schematic to automatically refactor: ng generate @angular/core:inject
https://angular.dev/reference/migrations/inject-function

Notes

Sub-issues

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions