Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use event.preventDefault() in AngularJS?

I have come across a method to avoid page refresh after form submission i.e event.preventDefault(); Being very new to Angular I really don't know how to put this syntax in my Angular controller, Is "event" an Angular service? How to use it in the code?

Any help would be appreciated!

like image 238
Dhruv Shrivastava Avatar asked Sep 07 '17 18:09

Dhruv Shrivastava


1 Answers

On every angular user interface events like ng-keyup ng-click etc you have access to $event object. f.ex ng-click="myClickHandler($event, otherData). you can call preventDefault on that $event object.

like image 165
Marcin Malinowski Avatar answered Oct 20 '22 00:10

Marcin Malinowski