Ng-Submit-2

 

Ng-Submit-2

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Welcome to LearnKode - A code learning platform</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> </head> <body ng-app="app"> <div ng-controller="ExampleController"> <div class="container"> <form name="emailForm" ng-submit="addMail()"> <label> Email: <input type="email" ng-model="email" class="form-control" placeholder="Email"><br /> <input ng-disabled="emailForm.$invalid" class="btn btn-primary" type="submit" value="Submit"> </label> <pre>{{showMail}}</pre> </form> </div> </div> <script> var app = angular.module("app", []); app.controller('ExampleController', ['$scope', function ($scope) { $scope.addMail = function () { $scope.showMail = $scope.email; $scope.email = ""; } }]); </script> </body> </html>
Output