Angular 2: Functions to be used across all components : <p>I have an angular 2 webpack project where I currently have some functions that are repeated throughout several components. I would like to inherit all of these components from a "master" class OR component (whichever works), in order to be able to call my functions from all my components that need them.</p>

<p>As an example, if I have a function foo in 3 different components:</p>

<pre><code>foo(s: string){
  console.log(s);
}
</code></pre>

<p>I would like you move this function to another file/class/components:</p>

<pre><code>class parent{
  foo(s: string){
    console.log(s);
  }
}
</code></pre>

<p>And having someway to call my foo function from my a given component. For instance:</p>

<pre><code>class child{
  constructor(){
    foo("Hello");
  }
}
</code></pre>

<p>How would I do this using Angular 2 / Typescript?</p>
