Last active
August 29, 2015 14:19
-
-
Save wholypantalones/a82d116566a1791305c3 to your computer and use it in GitHub Desktop.
Dynamic form post using angular w/ action
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form class="form-horizontal" name="chkForm" method="post" action="/this/is/an/action/" ng-submit="processThis(chkForm.$valid,$event)" novalidate> | |
/* the processThis function fires before the form action submits so we can hijack it. Passing $event allows for event.preventDefault() to be used | |
in the function in order to stop the form posting. https://docs.angularjs.org/api/ng/directive/ngSubmit | |
*/ | |
</form> | |
//in controller | |
$scope.processThis = function(isValid,e) { | |
if(isValid) { | |
e.preventDefault(); | |
// send to a service instead of the action | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment