Skip to main content

Sign Up Form Using AngularJS


In this code we will try to do Sign Up Form using AngularJS. The code is basically a register form without database in use. This will make you store any information temporarily by storing through array objects. To learn more about this, just follow the steps below.

Getting started:

First you will need to download & install the AngularJS here's the link https://angularjs.org/.

And this is the link for the bootstrap that i used for the layout design https://getbootstrap.com/.

Creating the Main Interface

This code contains the interface of the application. This code will render application and display the form. To do that just kindly write these block of code inside the text editor and save this as index.html.

  1. <!DOCTYPE html>
  2. <html lang="en" ng-app="myModule">
  3. <head>
  4. <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1"/>
  5. <link rel="stylesheet" type="text/css" href="css/bootstrap.css" />
  6. </head>
  7. <body ng-controller="myController">
  8. <nav class="navbar navbar-default">
  9. <div class="containet-fluid">
  10. <a class="navbar-brand" href="https://www.sourcecodester.com">Sourcecodester</a>
  11. </div>
  12. </nav>
  13. <div class="col-md-3"></div>
  14. <div class="col-md-6 well">
  15. <h3 class="text-primary">Sign Up Form Using AngularJS</h3>
  16. <hr style="border-top:1px dotted #ccc;"/>
  17. <div class="col-md-4">
  18. <form>
  19. <div class="form-group">
  20. <label>Firstname</label>
  21. <input type="text" class="form-control" ng-model="newUsers.firstname"/>
  22. </div>
  23. <div class="form-group">
  24. <label>Lastname</label>
  25. <input type="text" class="form-control" ng-model="newUsers.lastname"/>
  26. </div>
  27. <div class="form-group">
  28. <label>Username</label>
  29. <input type="text" class="form-control" ng-model="newUsers.username"/>
  30. </div>
  31. <div class="form-group">
  32. <label>Password</label>
  33. <input type="password" class="form-control" ng-model="newUsers.password"/>
  34. </div>
  35. <center><button class="btn btn-primary" ng-click="addUser()" data-dismiss="modal"><span class = "glyphicon glyphicon-save"></span> Sign up</button></center>
  36. </form>
  37. </div>
  38. <div class="col-md-8">
  39. <span class="pull-right">Show Password <input type="checkbox" ng-model="password"/></span>
  40. <table class="table table-bordered">
  41. <thead class="alert-info">
  42. <tr>
  43. <th>Firstname</th>
  44. <th>Lastname</th>
  45. <th>Username</th>
  46. <th>Password</th>
  47. </tr>
  48. </thead>
  49. <tr ng-repeat="user in users">
  50. <td>{{user.firstname}}</td>
  51. <td>{{user.lastname}}</td>
  52. <td>{{user.username}}</td>
  53. <td><span ng-hide="password">****</span><span ng-show="password">{{user.password}}</span></td>
  54. </tr>
  55. </tbody>
  56. </table>
  57. </div>
  58. </div>
  59. </body>
  60. <script src = "js/angular.js"></script>
  61. <script src = "js/script.js"></script>
  62. <script src = "js/bootstrap.js"></script>
  63. </html>

Creating the Main Function

This code contains the main function of the application. This code will store all the user information. To that just kindly copy and write these block of codes inside the text editor, then save it inside the js folder as script.js

  1. var app = angular.module("myModule", [])
  2. .controller("myController", function($scope){
  3.  
  4. $scope.newUsers = {};
  5.  
  6. $scope.users = [
  7. {firstname: "John", lastname: "Smith", username: "john123", password: "12345"},
  8. {firstname: "Claire", lastname: "Temple", username: "c123", password: "12345"}
  9. ];
  10.  
  11. $scope.addUser = function(){
  12. $scope.users.push($scope.newUsers);
  13. $scope.newUsers = {};
  14. };
  15.  
  16. });

There you have it we successfully created a Sign Up Form using AngularJS. I hope that this very simple tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!!

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Add new comment

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.