title: How to use a function of component1 in component2 in Angular 6 without interaction of HTML?
body: <p>I have testTry() function in Component1 which accepts one parameter and prints the value.</p>
  
  <pre><code>export class Component1 implements OnInit {
  
   testTry(name:any){
   console.log("Name--&gt;",name);}
  
   ngOnInit(){    }
  
  }
  </code></pre>
  
  <p>I have component2 with a function sampleCall() in which i need to call a function of component1 by sending a parameter</p>
  
  <pre><code>export class Component2 implements OnInit {
  
   sampleCall(){
    let a = "Sravya";
    testTry(a);
  }
  
   ngOnInit(){    }
  }
  </code></pre>
  
  <p>How would I call a function from component1 to component2 without involving HTML?</p>