title: Angular13: Share functions between components
body: <p>I have two functions in two differents components, I'd like to share functions between them but I don't understand how to do and applicate it in my project.
  In a component, I have a <strong>getDatasFromMainTable()</strong>.
  And on the other one, I have a <strong>getDatasFromArchiveTable()</strong>.
  I tried :</p>
  <pre><code>@Input() myFirstComponent!: MyfirstComponent;
  </code></pre>
  <p>and in a function:</p>
  <pre><code>this.myFirstComponent.getDatasFromArchiveTable();
  </code></pre>
  <p>But I have a message</p>
  <pre><code>Cannot read properties of undefined (reading 'getDatasFromArchiveTable')
  </code></pre>
  <p>I read a lot of things about behaviorSubject, or @Input(), @ViewChild() or onChanges... But I don't know how to applicate it to my project if I need it for this.</p>