• We just launched and are currently in beta. Join us as we build and grow the community.

JavaScript - Hide Password Using AngularJS

Kambe

Digital Currency Evangelist
K Rep
0
0
0
Rep
0
K Vouches
0
0
0
Vouches
0
Posts
135
Likes
188
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 100 XP
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 https://angularjs.org/.

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

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

    =

    "https://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"

    >

    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. ]

    ;

  8. $scope.users

    =

    users;

  9. $scope.content

    =

    undefined

    ;
  10. $scope.contentToggle

    =

    function

    (

    name)

    {
  11. if

    (

    $scope.isContentToggled

    (

    name)

    )

    {
  12. $scope.content

    =

    undefined

    ;
  13. }

    else

    {
  14. $scope.content

    =

    name;
  15. }
  16. }

  17. $scope.isContentToggled

    =

    function

    (

    name)

    {
  18. return

    $scope.content

    ==

    name;
  19. }
  20. }

    )

    ;

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!!


Download
You must upgrade your account or reply in the thread to view the hidden content.
 

452,496

335,120

335,128

Top