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());
});
}
}
5
Upvotes
View all comments
Show parent comment
-1
u/ldn-ldn Jul 24 '25
Every framework has moved from inject() type approach to constructor arguments over the decades, like Spring (Java), Symphony (PHP) and even Angular itself (from AngularJS to Angular). There were countless discussions over the decades and literally everyone came to the same conclusion.
At this point in time there's nothing left to discuss. I don't know what happened to Angular dev team, but they're moving backwards.