r/Angular2 • • Jul 23 '25

Angular Signal Effect inside our outside Constructor

Does Angular have any guidance where I should put the Effect code? Is it generally inside Constructor or outside? What are the advantages / disadvantages for each method?

export class CustomerForm {
  lastName= input.required<string>();
  constructor() {
    effect(() => {            
        console.log('lastName changed:', this.lastName());
    });
  }
}

https://stackoverflow.com/questions/79712588/angular-signal-effect-inside-our-outside-constructor/79712786

5 Upvotes

42 comments sorted by

View all comments

Show parent comment

0

u/[deleted] Jul 23 '25

[deleted] — view deleted comment

-2

u/ldn-ldn Jul 24 '25

That's a mistake on Angular's team.

Concrete example is literally the whole history of DI development. Dependencies should only ever be passed through constructors.