Ng-Click-4

 

In this example we can increase the count1 and count2 variable on click of anchor element and button respectively.isCheck is a variable with ng-model directive which set the value of checkbox to isCheck variable.If isCheck is true it will not increase count2 because ng-disabled directive disable the button.

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Welcome to LearnKode - A code learning platform</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> </head> <body ng-app="clickExample"> <div ng-controller="ExampleController"> Stop button counts: <input type="checkbox" ng-model="isCheck" /><br /> <a href="javascript:void:(0)" ng-click="count1=count1+1">Anchor</a> <input type="button" ng-disabled="isCheck" ng-click="count2=count2+1" value="Button" /><br /> Anchor Clicks: {{count1}}<br /> Button Clicks: {{count2}} </div> <script> var app = angular.module("clickExample", []); app.controller('ExampleController', ['$scope', function ($scope) { $scope.count1 = 0; $scope.count2 = 0; }]); </script> </body> </html>
Output