Angularjs修改密码的实例代码
修改密码逻辑思维
首先要输入旧的密码,判断旧的密码是否正确(后台判断)
其次输入新的密码,判断新密码格式(可增加)
最后判断新密码和确认密码输入是否一致
html部分
<form class="form-horizontal" role="form"> <div class="form-group"> <label class="col-sm-2 control-label"><i class="importance">*</i>当前密码</label> <div class="col-sm-6"> <input type="text" class="form-control" ng-model="user.password"> </div> </div> <div class="form-group"> <label class="col-sm-2 control-label"><i class="importance">*</i>新密码</label> <div class="col-sm-6"> <input type="text" class="form-control" ng-model="user.newPassword" ng-minlength="8" ng-maxlength="16" required> </div> </div> <div class="form-group"> <label class="col-sm-2 control-label"><i class="importance">*</i>确认新密码</label> <div class="col-sm-6"> <input type="text" class="form-control" ng-model="password_again"> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <button type="submit" class="btn btn-default x_submit" ng-click="changePassword()">保存设置</button> </div> </div> </form>
AngularJS部分
.controller('userpswdCtrl', 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:'', text: "修改成功", type: "success", showCancelButton: false, confirmButtonColor: "#DD6B55", confirmButtonText: "是", cancelButtonText: "否", closeOnConfirm: true, closeOnCancel: true }) },function(){ }) } } })
以上所述是小编给大家介绍的Angularjs修改密码的实例代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对我们网站的支持!
赞 (0)