手机版

Angular.js是获取验证码60秒倒计时按钮的简单方法

时间:2021-09-03 来源:互联网 编辑:宝哥软件园 浏览:

主要介绍Angular.js获取验证码60秒倒计时按钮的相关内容,相信这个功能没有必要介绍,大家都很熟悉,下面就不多说了。我们来看看实现方法。

一、控制器中的代码

angular.module('控制器')。controller('LoginCtrl ',function ($scope,$location,$ ionicLoading,$rootScope,$interval,$ time out){ $ scope . timer=false;$ scope.timeout=60000$ scope . timer COunt=$ scope . time out/1000;$scope.text=“获取验证码”;$ scope . onclick=function(){ $ scope . show timer=true;$ scope.timer=true$scope.text=“以秒为单位重新获取”;var计数器=$ interval(function(){ $ scope . timer count=$ scope . timer count-1;}, 1000);$ time out(function(){ $ scope . text=' get验证码';$ scope.timer=false$interval.cancel(计数器);$ scope.showTimer=false$ scope . timer COunt=$ scope . time out/1000;},$ scope . time out);};});第二,在html页面中

button class=' yz-BTN ' ng-click=' onclick()' ng-disabled=' timer ' span ng-if=' show timer ' { timer count } }/span { { text } }/button注意:

1.class='yz-btn '是按钮的样式,可以自行修改;

2.ng-disabled='timer '控制按钮是否可以点击;

3.ng-if='showTimer '控制数字显示;

4.ng-click='onClick()'触发效果,文本文本默认为“获取验证码”,点击后为“60s后再获取”。

第三,效果图

1.单击前

2.点击后,

摘要

以上就是本文的全部内容。希望本文的内容对大家的学习或工作有一定的参考价值。有问题可以留言交流。谢谢你的支持。

版权声明:Angular.js是获取验证码60秒倒计时按钮的简单方法是由宝哥软件园云端程序自动收集整理而来。如果本文侵犯了你的权益,请联系本站底部QQ或者邮箱删除。