title: Run a Service Function inside an Angular Routing Module class
body: <p>So the basic story...</p>
  
  <p>At the top of this SPA is a 'top-bar' component, and inside that component is a search-bar component.</p>
  
  <p>Now - there are a few 'landing pages' where we want to turn this search-bar component off.</p>
  
  <p>I understand the process of using this through a service (since the 'landing pages' in question aren't directly connected to the search-bar component.  And in and of itself - I had this working...</p>
  
  <p>The problem comes from the fact that if you land on one of these landing pages, and this search-bar gets turned off...  If you leave the whole section and go to a different area that needs that bar on, you have to add this service to 'every possible route' (and there are dozens), as well as in the future, adding this service and 'turn on' code to any new pages in the SPA.</p>
  
  <p>What I was wondering (well first: if this proposed idea is the best way to go about it, or if there was another way that's better) if there was some way to add a function in the few routing module classes we use (one for each 'section' of the SPA) that would by default turn the search-bar component on - and the the individual landing pages could turn it off if wanted (so that I'd only have to add the service to the routing modules and the specifically needed landing pages), but if you left that landing page via the menu and went to a complete other section of the SPA, the search-bar would automatically be turned back on (because whatever routing module turned it back on).</p>
  
  <p>I hope that makes sense!  </p>