An angular directive which automatically disables a button and counts down. Used for buttons sending SMS codes.
Using bower:
bower install --save angular-sms-buttonOr just download the source code and reference angular-sms-button.min.js.
- Add dependency to your app.
angular
.module('myApp', ['angular-sms-button', ...])- 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();
...- 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";
};
}])See examples here.