JavaScript - Hide Password Using AngularJS

Submitted by: 
Visitors have accessed this post 138 times.

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="<a href="">Sourcecodester</a>
  11. " rel="nofollow">">Sourcecodester</a>
  12. </a> </div>
  13. </nav>
  14. <div class="col-md-3"></div>
  15. <div class="col-md-6 well">
  16. <h3 class="text-primary">JavaScript - Hide Password Using AngularJS</h3>
  17. <hr style="border-top:1px dotted #ccc;"/>
  18. <button type="button" ng-click="contentToggle('password')" class="btn btn-primary">Hide Password</button>
  19. <br /><br />
  20. <table class="table table-bordered">
  21. <thead class="alert-info">
  22. <tr>
  23. <th>Firstname</th>
  24. <th>Lastname</th>
  25. <th>Age</th>
  26. <th>Username</th>
  27. <th ng-hide="isContentToggled('password')">Password</th>
  28. <th ng-show="isContentToggled('password')">Password</th>
  29. </tr>
  30. </thead>
  31. <tbody style="background-color:#fff;">
  32. <tr ng-repeat="user in users">
  33. <td>{{user.firstname}}</td>
  34. <td>{{user.lastname}}</td>
  35. <td>{{user.age}}</td>
  36. <td>{{user.username}}</td>
  37. <td ng-hide="isContentToggled('password')">{{user.password}}</td>
  38. <td ng-show="isContentToggled('password')">*****</td>
  39. </tr>
  40. </tbody>
  41. </table>
  42. </div>
  43. <script src="js/angular.js"></script>
  44. <script src="js/script.js"></script>
  45. </body>
  46. </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!!

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.