My HTML form is set up within an Angular controller with inputs, action, and other elements already defined. The only issue I'm facing is that the form does not have a traditional submit button. Instead, there is a separate button on the page outside of the form that needs to initiate the submission process when clicked. Essentially, I want the external button to function as a standard submit button.
For instance (using a simplified version of my current setup),
<div ng-controller='sendFormController">
<form name='my_form' action='/path/to/form_handler.php' method="POST">
<input type="text" name="form_data" />
</form>
<button ng-click='submitForm()">Send Data</button>
</div>
I've searched for a solution to this dilemma, but the options I found seem a bit like hacks in my opinion, including:
- Using a hidden submit button and triggering it with the external button.
- Writing code that performs $http.post(), etc. when the external button is clicked. I prefer not to duplicate actions and parameters in the function.
I believe there must be a straightforward way in Angular to simply execute the form submission, yet I couldn't find it in the documentation. Can someone guide me towards the solution I'm missing?