0

I want to click Save button when I press Enter..For this, I created a directive named "onEnter" but I don't know how to trigger 'ng-click' on savebutton wheen Enter key press. I made a sample here

http://plnkr.co/edit/vnphuxQRQQfVmWtsGhip?p=preview

Please suggest!

Ammar Khan
  • 346
  • 1
  • 9
  • 27

1 Answers1

0

If you change:

<input type="button".. value="Save" />

to

<input type="submit".. value="Save"/>

Then the form will act normally listening for the enter event. No need for a directive as it is already built in.

Angular also supports an ng-submit event. This post will provide more information:

Submit form on pressing Enter with AngularJS

Community
  • 1
  • 1
SamV
  • 7,548
  • 4
  • 39
  • 50