Two ways:
- Put the function in a shared service and execute from there
- Get the component object and call the function from there:
Lets say your component name is "TestComponent", then:
Add a selector id #test to your selector in test.component.html
<test #test></test>
Get the TestComponent in your the component where you want to call the function:
@ViewChild('test')
private testComponent: TestComponent;
/* Remember to import the TestComponent in the file where you get this */
Call the method you want to execute. The method must be public in your TestComponent. E.g.
this.testComponent.registerUser();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…