I have a component that only contains a form and a function to submit the form.
submitData(newUserForm: NgForm)
How can I trigger this function from another component, when I click a button?
I embed the form component like this:
<app-form></app-form>
But it's not created in the main component and I cannot import it, like a child component.
I have a service in the main component but the form component doesn't have access to it.
I have found this but nothing seem to work for me.
How to call another components function in angular2
In the main component I need a function that should call the submit function from the form:
Something like:
save() {
submitData();
}
Does it work with something like Hostlistener, dispatchEvent or runOutsideAngular?
I have found some samples but nothing seem to work.