Skip to content

Conversation

@giebelan
Copy link
Collaborator

@giebelan giebelan commented Nov 25, 2025

Guide und schematic: https://angular.dev/reference/migrations/inject-function

Den müssen wir nicht unbedingt mergen finde ich. Konstruktor Injection funktioniert ja. Die Argumente für und gegen sind auch ein bisschen esoterisch finde ich...

Aber Angular pushed halt schon in die Richtung inject() und deshalb hätte ich es jetzt einfach gemacht.

constructor(
private appStateService: AppStateService,
private dataRepoService: DataRepositoryService,
private logger: Logger, @Inject(LOCALE_ID) private localeId: string,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hier ist tatsächlich ein Fall, wo Konstruktor basierte Injektion problematisch war. localeId wird gar nicht mehr verwendet und kann somit gestrichen werden. Meine IDE hat das zumindest vor dem Refactoring nicht angezeigt. Nach dem Refactoring schon.

@giebelan giebelan requested a review from BGruenberg November 25, 2025 11:18
@BGruenberg
Copy link
Collaborator

Kannst du einmal die Konflikte beheben?

Comment on lines +27 to +34
private min = inject(new HostAttributeToken('minLength'));

validator: Function;

constructor(@Attribute('minLength') private min: number) {
this.validator = minLengthArrayValidator(min);
constructor() {
const min = this.min;

this.validator = minLengthArrayValidator(Number(min));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private min = inject(new HostAttributeToken('minLength'));
validator: Function;
constructor(@Attribute('minLength') private min: number) {
this.validator = minLengthArrayValidator(min);
constructor() {
const min = this.min;
this.validator = minLengthArrayValidator(Number(min));
validator: Function;
constructor() {
const min = inject(new HostAttributeToken('minLength'));
this.validator = minLengthArrayValidator(Number(min));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants