Skip to main content

JavaScript - Hide Password Using AngularJS

In this tutorial we will create a Hide Password Using AngularJS. AngularJS is a structural framework for dynamic web apps. It is a kind of template that extends HTML to a new level of coding techniques. It is mostly used by other well known site for creating a template.

Getting started:

First you will need to download & install the AngularJS here's the link

And this is the link for the bootstrap that i used for the layout design

The Main Interface

This code contains the interface of the application. This code will render application and display the form. To create this just 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="container-fluid">
  10. <a class="navbar-brand" href="">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">JavaScript - Hide Password Using AngularJS</h3>
  16. <hr style="border-top:1px dotted #ccc;"/>
  17. <button type="button" ng-click="contentToggle('password')" class="btn btn-primary">Hide Password</button>
  18. <br /><br />
  19. <table class="table table-bordered">
  20. <thead class="alert-info">
  21. <tr>
  22. <th>Firstname</th>
  23. <th>Lastname</th>
  24. <th>Age</th>
  25. <th>Username</th>
  26. <th ng-hide="isContentToggled('password')">Password</th>
  27. <th ng-show="isContentToggled('password')">Password</th>
  28. </tr>
  29. </thead>
  30. <tbody style="background-color:#fff;">
  31. <tr ng-repeat="user in users">
  32. <td>{{user.firstname}}</td>
  33. <td>{{user.lastname}}</td>
  34. <td>{{user.age}}</td>
  35. <td>{{user.username}}</td>
  36. <td ng-hide="isContentToggled('password')">{{user.password}}</td>
  37. <td ng-show="isContentToggled('password')">*****</td>
  38. </tr>
  39. </tbody>
  40. </table>
  41. </div>
  42. <script src="js/angular.js"></script>
  43. <script src="js/script.js"></script>
  44. </body>
  45. </html>

Creating the Script

This code contains the script of the application. This code will hide the password when the button is clicked. To do this just copy write the code as shown below inside the text editor and save it as script.js.

  1. var app = angular.module("myModule", [])
  2. .controller("myController", function($scope){
  3. var users = [
  4. {firstname: "Angelo", lastname: "Borg", age: "35", username: "borg123", password: "12345"},
  5. {firstname: "Jane", lastname: "watson", age: "16", username: "watson", password: "jane123"},
  6. {firstname: "Karl", lastname: "Heron", age: "21", username: "heron", password: "12345678"},
  7. ];
  9. $scope.users = users;
  11. $scope.content = undefined;
  12. $scope.contentToggle = function(name){
  13. if ($scope.isContentToggled(name)){
  14. $scope.content = undefined;
  15. } else {
  16. $scope.content = name;
  17. }
  18. }
  20. $scope.isContentToggled = function (name){
  21. return $scope.content == name;
  22. }
  23. });

There you have it we successfully created a Hide Password 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 for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.


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

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