Home Web Front-end JS Tutorial Example code sharing of how to use Angularjs to change password

Example code sharing of how to use Angularjs to change password

May 27, 2017 pm 01:14 PM

This article mainly introduces the example code of Angularjs. It is very good and has reference value. Friends in need can refer to it

Modify password logical thinking

First enter the old password to determine whether the old password is correct (backend judgment)

Secondly enter the new password and determine the new password format (can be Add)

Finally determine whether the new password and confirmed password input are consistent

html part

<form class="form-horizontal" role="form">
 <p class="form-group">
  <label class="col-sm-2 control-label"><i class="importance">*</i>当前密码</label>
  <p class="col-sm-6">
   <input type="text" class="form-control" ng-model="user.password">
  </p>
 </p>
 <p class="form-group">
  <label class="col-sm-2 control-label"><i class="importance">*</i>新密码</label>
  <p class="col-sm-6">
   <input type="text" class="form-control" ng-model="user.newPassword" ng-minlength="8" ng-maxlength="16" required>
  </p>
 </p>
 <p class="form-group">
  <label class="col-sm-2 control-label"><i class="importance">*</i>确认新密码</label>
  <p class="col-sm-6">
   <input type="text" class="form-control" ng-model="password_again">
  </p>
 </p>
 <p class="form-group">
  <p class="col-sm-offset-2 col-sm-10">
   <button type="submit" class="btn btn-default x_submit" ng-click="changePassword()">保存设置</button>
  </p>
 </p>
</form>
Copy after login

AngularJS part

.controller(&#39;userpswdCtrl&#39;, function($scope,Account,SweetAlert,$state,$localStorage){
 $scope.user = {}; //信息全部存在user里面
 $scope.changePassword = function(){
  if($scope.password_again === $scope.user.newPassword){  //如果两次密码输入一致
    $scope.user.accountId = $localStorage.accountId;   //获取用户id
    Account.modifyPassword($scope.user,function(data){  //修改密码
     console.log(data);
     SweetAlert.swal({
      title:&#39;&#39;,
      text: "修改成功",
      type: "success",
      showCancelButton: false,
      confirmButtonColor: "#DD6B55",
      confirmButtonText: "是",
      cancelButtonText: "否",
      closeOnConfirm: true,
      closeOnCancel: true
     })
    },function(){

    })
  }
 }
})
Copy after login

The above is the detailed content of Example code sharing of how to use Angularjs to change password. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to change the password of Amap_How to change the password of Amap How to change the password of Amap_How to change the password of Amap Apr 01, 2024 pm 01:56 PM

1. First find [Amap] on your mobile phone and open it. 2. Then switch to the [My] tab and click the settings icon in the upper right corner to enter. 3. Click [Account and Security] to enter. 4. Then click [Login Password] to enter. 5. Finally enter the password and click [Confirm Modification] to complete.

How to change password on Xiaomi door lock_Tutorial on changing password on Xiaomi door lock How to change password on Xiaomi door lock_Tutorial on changing password on Xiaomi door lock Mar 25, 2024 am 11:40 AM

1. Open the Mijia app on your phone and click Mijia Smart Door Lock. 2. Verify the security password through numbers, fingerprints or faces. 3. Select the user whose password needs to be changed. 4. You can delete the user and then add the user to set a new password, or you can add a new password directly.

The latest 5 angularjs tutorials in 2022, from entry to mastery The latest 5 angularjs tutorials in 2022, from entry to mastery Jun 15, 2017 pm 05:50 PM

Javascript is a very unique language. It is unique in terms of the organization of the code, the programming paradigm of the code, and the object-oriented theory. The issue of whether Javascript is an object-oriented language that has been debated for a long time has obviously been There is an answer. However, even though Javascript has been dominant for twenty years, if you want to understand popular frameworks such as jQuery, Angularjs, and even React, just watch the "Black Horse Cloud Classroom JavaScript Advanced Framework Design Video Tutorial".

How to change password in MySQL How to change password in MySQL Sep 22, 2023 am 10:25 AM

Methods for changing passwords in MySQL include using the SET PASSWORD statement, using the ALTER USER statement, using the mysqladmin tool, using MySQL Workbench, etc. Detailed introduction: 1. Using the SET PASSWORD statement is the simplest way to modify the MySQL password; 2. Using the ALTER USER statement. Starting from MySQL version 5.7.6, you can use the ALTER USER statement to modify the user's password, etc.

What are the methods to change password in MySQL? What are the methods to change password in MySQL? Sep 26, 2023 am 10:28 AM

Methods for changing the password in MySQL include using command line tools to change the password, using MySQL Workbench to change the password, using phpMyAdmin to change the password, etc. Detailed introduction: 1. Use the command line tool to change the password, open a terminal or command prompt window, enter the MySQL installation directory, enter the following command to log in to the MySQL server "mysql -u username -p", the username is the MySQL username, The -p parameter indicates that you need to enter a password. After entering the password, press Enter to log in, etc.

Use PHP and AngularJS to build a responsive website to provide a high-quality user experience Use PHP and AngularJS to build a responsive website to provide a high-quality user experience Jun 27, 2023 pm 07:37 PM

In today's information age, websites have become an important tool for people to obtain information and communicate. A responsive website can adapt to various devices and provide users with a high-quality experience, which has become a hot spot in modern website development. This article will introduce how to use PHP and AngularJS to build a responsive website to provide a high-quality user experience. Introduction to PHP PHP is an open source server-side programming language ideal for web development. PHP has many advantages, such as easy to learn, cross-platform, rich tool library, development efficiency

Build web applications using PHP and AngularJS Build web applications using PHP and AngularJS May 27, 2023 pm 08:10 PM

With the continuous development of the Internet, Web applications have become an important part of enterprise information construction and a necessary means of modernization work. In order to make web applications easy to develop, maintain and expand, developers need to choose a technical framework and programming language that suits their development needs. PHP and AngularJS are two very popular web development technologies. They are server-side and client-side solutions respectively. Their combined use can greatly improve the development efficiency and user experience of web applications. Advantages of PHPPHP

How to change account password on DingTalk_Steps to change login password on DingTalk How to change account password on DingTalk_Steps to change login password on DingTalk Mar 29, 2024 pm 06:16 PM

1. Select the message option in DingTalk software. 2. Then click your profile picture in the upper left corner. 3. Then on the personal page, select and open the settings option. 4. Select the Security Center option on the settings page. 5. Then we open the account setting options. 6. On the Account and Security page, click the Password option. 7. Then we need to enter the original password. 8. Finally, we can set and enter a new password.

See all articles