Two ways:
- Put the function in a shared service and execute from there
- Get the component object and call the function from there:
Let's say your component name is "TestComponent", then:
Add #test selector id to your selector in test.component.html
<test #test></test>
Get the TestComponent in your component where you want to call the function:
@ViewChild('test') private testComponent: TestComponent;
Call the method you want to execute. This method should be publicly available in your TestComponent. For instance.
this.testComponent.registerUser ();
source share