"Exactly 1 value to be increased or decreased"
<div ng-controller="CounterController"> <button ng-click="increment();"> Increment </button> count: {{count}} <button ng-click="decrement();"> Decrement </button> <div>
Controller:
angular.module('myApp', []) .controller('CounterController', function($scope) { var incremented = false; var decremented = false; $scope.count = 15; $scope.increment = function() { if (incremented) { return; } $scope.count++; incremented = true; }; $scope.decrement = function() { if (decremented) { return; } $scope.count--; decremented = true; }; });
If you want the user to be able to do this many times, then ...
angular.module('myApp', []) .controller('CounterController', function($scope) { $scope.count = 15; var max = $scope.count + 1; var min = $scope.count - 1; $scope.increment = function() { if ($scope.count >= max) { return; } $scope.count++; }; $scope.decrement = function() { if ($scope.count <= min) { return; } $scope.count--; }; });
JS Fiddle - http://jsfiddle.net/HB7LU/8673/
source share