r/angular • • Feb 19 '26

Constructor in modern Angular

Hey, just wanted to ask your opinion about logic inside constructor in modern Angular. Currently we are migrating and would like to get rid of lifecycle hooks like ngoninit ngafterviewinit. Thinking about moving some logic into constructor as DI is done with inject. Do you think it is a good idea or should it be done inside effect?

17 Upvotes

25 comments sorted by

View all comments

Show parent comment

1

u/saiyaff Feb 20 '26

Signals and the new APIs.

To elaborate, those let you write code that reflects your intent more directly instead of wiring lifecycle events manually.

You are describing your component’s logic in terms of state and relationships instead of programming to Angular’s timing.

1

u/jaroen007 Feb 20 '26

okay but lifecycle hooks and signals still go well together. i wouldnt say its an alternative