Is it possible to add global lifecycle hooks for every component instead of doing it one by one ? Example: I want on each component initialization to be called a function.
Asked
Active
Viewed 161 times
0
-
No, not that i'm aware of since lifecycle events are per instance. – David L Jul 11 '16 at 20:01
-
Take a look at answer provided in this [post](https://stackoverflow.com/questions/39420241/angular-2-global-lifecycle-hooks) – Shubham Takode Nov 19 '19 at 11:19
1 Answers
0
I believe that's not officially possible.
I haven't seen an example like this in the Angular 2 docs. The component lifecycle events are implemented per instance.
PS: If you find a hackish way to do it, I wouldn't recommend you to do so. I bet there's a better alternative to handle your use-case :)

Kaloyan Kosev
- 12,483
- 8
- 59
- 90