Angular.js using the Get Verification Code button Implementation-Countdown

Source: Internet
Author: User

Get Verification Code Interface effect

You need to implement the following logic

button is not selectable

--Enter phone number, button optional

--Click to get, enter the countdown, button is not selectable

-Countdown to the end, back to the first state of knowledge

Core code:

var cd =; var function () {    cd--;     = "Regain" +1000, 60);

Full code:

Html:

 <formname= "form"class= "Form-validation">          <Divclass= "List-group list-group-sm">            <Divclass= "List-group-item">              <inputtype= "text"placeholder= "Phone"class= "Form-control no-border"Ng-model= "Seller.phone"Required>            </Div>            <Divclass= "List-group-item">                  <inputstyle= "width:150px;float:left;border:1px solid #DDD;"type= "Phone"placeholder= "4-bit verification Code"class= "Form-control no-border"Ng-model= "Seller.verification"Required>                <Buttonstyle= "width:150px;float:right;"type= "button"class= "btn btn-primary btn-block"Ng-click= "sendverification ()"ng-disabled= '!seller.phone| | Send '>{{countdown}}</Button>                <Divclass= "Clearfix"></Div>            </Div>            <Divclass= "List-group-item">               <inputtype= "Password"placeholder= "Password"class= "Form-control no-border"Ng-model= "Seller.password"Required>            </Div>          </Div></form>

Js:

App.controller (' Signupformcontroller ', [' $interval ', ' $scope ', ' $http ', ' $state ',function($interval, $scope, $http, $state) {$scope. Countdown= "Get Verification Code"; $scope. Loginmsg=""; $scope. Send=false; $scope. Sendverification=function() {$http. Post (' http://localhost:8083/boronManager/seller/verification/' + $scope. Seller.phone, {verificationtype:1}). Then (function(response) {varreq =Response.data; if(!req.success) $scope. Autherror=Req.error; }, function(x) {$scope. Autherror=Response.data.error;        }); varcd = 60; varToDo =function() {$scope. Send=true; CD--; if(CD < 0) {CD= ""; $scope. Send=false; } $scope. Countdown= "Get back" +cd;        }; $interval (ToDo,1000, 60); };}]);

Angular.js using the Get Verification Code button Implementation-Countdown

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.