Ng-Click-3

 

In this example we can increase or decrease the value of count variable.In first button click we can decrease the value of count and on second button click we can increase the value of count because ng-click directive increase or decrease the value of count.

 
 
 
<!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"> <button ng-click="count=count-1"><i class="glyphicon glyphicon-chevron-left"></i></button> <button class="btn btn-primary btn-sm">{{count}}</button> <button ng-click="count=count+1"><i class="glyphicon glyphicon-chevron-right"></i></button> </div> <script> var app = angular.module("clickExample", []); app.controller('ExampleController', ['$scope', function ($scope) { $scope.count = 0; }]); </script> </body> </html>
Output