user675712 user675712 - 1 year ago 120
AngularJS Question

Angularjs default action when Enter key is pressed

My understanding with forms, is that if the form has an ng-submit action associated with it, then pressing the Enter key would invoke that action, typically mimicking the click of the form's "submit" button. I have a form that does not have have a button, but a custom image of a button within a div tag and the div tag has the ng-click action. When I press Enter, nothing happens. What am I missing?

Answer Source

Make your button type submit and add a class attribute and style your button to make it an image like:

<form ng-submit="someAction()">
 <button type="submit" class="submitbutton">Submit</button>

And do style your button in css like:

.submitbutton {
  background:url('....') // your custom image

Then your custom image will act as the submit button and invoke the form action when click the enter key.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download