Description
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
- We may need a doc (Angular - Updating documentation for the inject function migration #23270) or blog issue for this