title: Write global functions to use in all components in angular
body: <p><strong>Note : Its not for global variable but for a global common function to perform a functionality on all components</strong> </p>
  
  <p>I am working on an angular app where I have around 400 components in different modules, almost all components have one same kind of functionality as mentioned below</p>
  
  <p>There is a sections on many pages which shows a "How to work section" which can be closed by users and will remain closed unless they open it again, I have done it with cookies which I set on click on close or open icon but this function is written in a component and this needs to be imported in other components</p>
  
  <p>I want to create a functions somewhere which perform this functionality on click on icon and can be called without importing any component in others.</p>
  
  <p>One way to do it ( as I thought ) could be create a JavaScript function in a file and load it in index file and then call this function on click on close and open icon </p>
  
  <p>Not sure if this is the best way to do this. Hope someone will come up with a better solution.</p>