Hooking into the Angular bootstrap process #113
Replies: 2 comments 2 replies
-
Hi Max, Thanks for the rare and awesome articles. I need your advise for one of the requirement I have in my Angular application. I have a number of components embedded in various number of parent components and some of the components are lazy loaded by routing. I have a code which has to execute in every component's instantiation or initialization process. I am not allowed to hook this logic in ngOnInit or constructor of the individual components by the requirement because I have a large number of components which has to execute this logic and there are large number of developers working in this project and every developer cannot be asked to hook this from there component's ngOnInit or constructor and this particular logic has to execute for the new components that gets added to the application as well. So is it possible by any chance in Angular to listen to every component's initialization or instantiation in a single place. Could you please advise me on how to fix this problem or point me to any of your articles which already covers this problem. Thanks in advance, |
Beta Was this translation helpful? Give feedback.
-
Thanks for your response Max. My project is into logistics domain and the application has three common context objects - countryConfigObject, LoggedInUserContextObject and ShippmentObject. This logic is going to execute some strategies by considering some inputs from these context objects to know whether the component can be shown or not shown in the page. Every component in my application has an unique id. So what i am trying to do is find a place which listens to every component's initialization or instantiation and execute this logic. |
Beta Was this translation helpful? Give feedback.
-
From this article you'll learn how to use APP_INITIALIZER token and bootstrapModule to hook up into Angular's initialization process.
Read the article here.
Beta Was this translation helpful? Give feedback.
All reactions