Prev Demo
AngularJS
>
Ng-Submit Events
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> </head> <body> <h1>AngularJS ng-submit examples</h1> <script> var app = angular.module("app", []); app.controller("NgSubmitController", ['$scope', function ($scope) { $scope.SubmitLogin = function () { // validate data, format data and send to server $scope.FormData = "Username: " + $scope.Username + ", Password: " + $scope.Password; }; }]); </script> <div ng-app="app" ng-controller="NgSubmitController"> <form ng-submit="SubmitLogin()" > <table> <tr><th colspan="2">Login</th></tr> <tr><td>Username: </td><td><input type="text" name="txtLogin" ng-model="Username" placeholder="Enter username" /></td></tr> <tr><td>Password: </td><td><input type="password" name="txtPassword" ng-model="Password" placeholder="Enter password" /></td></tr> <tr><td> </td><td><input type="submit" value="Submit" /></td></tr> </table> </form> <hr /> <p>{{ FormData }}</p> </div> </body> </html>
Note: We DO NOT save your trial code in our database.
Output