Skip to content

laohyx/angular-sms-button

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

angular-sms-button

An angular directive which automatically disables a button and counts down. Used for buttons sending SMS codes.

Installation

Using bower:

bower install --save angular-sms-button

Or just download the source code and reference angular-sms-button.min.js.

Usage

  1. Add dependency to your app.
angular
    .module('myApp', ['angular-sms-button', ...])
  1. Use it as a HTML tag

In HTML file:

<button sms-button sms-button-model="button1" ng-click="button1.start()"></button>

In your controller:

.controller('myController', ['$scope', 'SmsButton' ,function($scope, SmsButton) {
    $scope.button1 = new SmsButton();
    ...
  1. More configuration

You can configure the button with construtor parameters.

// in controller
$scope.button1 = new SmsButton({
    initText: "Click to send",
    waitSeconds: 3,
    waitTextFormatter: function (seconds) {
        return "Wait "+seconds+" seconds to resend";
    },
    onStop: function () {
        alert("stopped!");
    }
});

Or just using providers

 .config(['SmsButtonConfigProvider', function(SmsButtonConfigProvider) {
     SmsButtonConfigProvider.initText = 'Click to send';
     SmsButtonConfigProvider.waitSeconds = 3;
     SmsButtonConfigProvider.waitTextFormatter = function(seconds) {
        return "Wait "+seconds+" seconds to resend";
     };
 }])

More details

See examples here.

About

An angular directive which automatically disables a button and counts down. Used for buttons sending SMS codes.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors