Angularjs enable disable button
home
Run
screen_rotation
fullscreen
cloud_download
<!DOCTYPE html> <html lang="en"> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script> <script> var myApp = angular.module("myApp", []); myApp.controller("myController", function($scope,$timeout) { $scope.myBtn = false; $scope.demoButton = "Demo Button"; $scope.enableDisableButton = function() { $scope.myBtn = true; $scope.demoButton = "Please Wait...."; //do your stuffs Such as get data from ajax //... //... // We are using timeout for this example as // we are not using ajax or some other activity. // Note $timeout service must be imported for using timeout. $timeout(function () { $scope.demoButton = "Demo Button"; $scope.myBtn = false; // enable button after 3 seconds. }, 3000); }; }); </script> </head> <body> <div ng-app="myApp"> <div ng-controller="myController"> <button ng-disabled="myBtn" ng-model='myBtn' ng-click='enableDisableButton()' >{{demoButton}}</button> </div> </div> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script> <script> var myApp = angular.module("myApp", []); myApp.controller("myController", function($scope,$timeout) { $scope.myBtn = false; $scope.demoButton = "Demo Button"; $scope.enableDisableButton = function() { $scope.myBtn = true; $scope.demoButton = "Please Wait...."; //do your stuffs Such as get data from ajax //... //... // We are using timeout for this example as // we are not using ajax or some other activity. // Note $timeout service must be imported for using timeout. $timeout(function () { $scope.demoButton = "Demo Button"; $scope.myBtn = false; // enable button after 3 seconds. }, 3000); }; }); </script> </head> <body> <div ng-app="myApp"> <div ng-controller="myController"> <button ng-disabled="myBtn" ng-model='myBtn' ng-click='enableDisableButton()' >{{demoButton}}</button> </div> </div> </body> </html>
Copyrights@tutorialsplane.com