Maybe the answer to this question is relevant for AngularJS (1.x) also, but my question here is for Angular 2 and above.
As we know, every component file has its own ngOnInit function, which runs the code inside of it when the component initializes. In my current application, I need to run the same piece of code in ALL these functions, in ALL the components, and automatically. Right now, I just copy the code between these functions, for each component's TS file. Is there a way of putting this code once in a common place and have all these init functions run it from there, automatically? Meaning, even brand new components added to the app will run this code, as part of their init function...