Ng-Submit-8

 

Ng-Submit-8

 
 
 
<!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"> <h3>Login</h3> <form name="editForm" ng-submit="login()" ng-hide="isShow"> User Name: <input type="text" ng-model="records.userName" required class="form-control" /> Password: <input type="password" ng-model="records.password" required class="form-control" /><br /> <button class="btn btn-primary" ng-disabled="editForm.$invalid">Login</button> </form> <br> <pre ng-show="isShow"><h4>Welcome <b>{{name}}</b> You are successfully login</h4></pre> <input ng-show="isShow" class="btn btn-default" type="button" value="Logout" ng-click="isShow=false" /> </div> </div> <script> var app = angular.module("app", []); app.controller('ExampleController', ['$scope', function ($scope) { $scope.records = { userName: "", password: "" }; $scope.login = function () { $scope.isShow = true; $scope.name = $scope.records.userName; $scope.records = { userName: "", password: "" } }; }]); </script> </body> </html>
Output