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.

0

1 Answer 1

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">
Sign up to request clarification or add additional context in comments.

3 Comments

This will recognize every click, I meant that I want to recognize only ENTER.
This dose not work in firefox
For new versions of angular you can use: (keyup.enter)="someFunction()"

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.