20

is there a way to trigger event when clicking on ENTER key in the input field? I found a directive that someone suggested to use, but I wonder if there is a simple way to do it.

I am using angular 1.3.

orikoko
  • 881
  • 5
  • 15
  • 26

1 Answers1

46
 $timeout(function() {
     angular.element('#myselector').trigger('click');
  }, 100);

If you want trigger on press on enter key you need to write like that

<input ng-keyup="$event.keyCode == 13 ? myFunc() : null">
Neeraj Dubey
  • 4,401
  • 8
  • 30
  • 49