Implementation of the 60-second countdown function of AngularJS verification code and angularjs Verification Code
Recently I am working on the AngularJS project. This is a 60-second countdown. Unlike jq, angularjs does not use dom node operations, but data operations and write countdown. It is best to use $ timeout and $ interval, do not use settimeout and setinterval. $ Timeout and $ interval can directly update the bound data.
Html
<A href = "javascript:" rel = "external nofollow" ng-click = "sendphonecode (reg_phone) "ng-class =" paraclass "ng-bind =" paracont "> obtain the Verification Code </a>
Angularjs
Angular. module ('controllers', []). controller ('registerctrl ', function ($ scope, $ interval) {$ scope. paracont = "get verification code"; $ scope. paraclass = "but_null"; $ scope. paraevent = true; var second = 60, timePromise = undefined; timePromise = $ interval (function () {if (second <= 0) {$ interval. cancel (timePromise); timePromise = undefined; second = 60; $ scope. paracont = "resend verification code"; $ scope. paraclass = "but_null"; $ scope. paraevent = true;} else {$ scope. paracont = second + "resend after seconds"; $ scope. paraclass = "not but_null"; second -- ;}, 1000,100 );});
The above is the implementation of the 60-second countdown function of AngularJS Verification Code introduced by xiaobian. I hope it will help you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!