Ниже есть код, но decrement уходит в минус, как сделать чтобы не уходило в минус?
вот исправил как то так
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
<script> angular.module("CounterApp", [])
.controller("CounterController1", function($scope) {
$scope.a = 0;
$scope.b = 0;
$scope.c = 0;
$scope.decrement = function() {
if ($scope.a > 0) $scope.a--;
if ($scope.b > 0) $scope.b--;
if ($scope.c > 0) $scope.c--;
} })
</script>
</head>
<body>
<div ng-app="CounterApp">
<div ng-controller="CounterController1"> <button ng-model="a" type="number" ng-click="decrement()">Decrement</button> {{a}} <button ng-model="a" type="number" ng-click="a = a + 1">Increment</button> </div>
<div ng-controller="CounterController1"> <button ng-model="b" type="number" ng-click="decrement()">Decrement</button> {{b}} <button ng-model="b" type="number" ng-click="b = b + 1">Increment</button> </div>
<div ng-controller="CounterController1"> <button ng-model="c" type="number" ng-click="decrement()">Decrement</button> {{c}} <button ng-model="c" type="number" ng-click="c = c + 1">Increment</button>
</div>
</div>
<h1>{{ a + b + c }}</h1>
</body>
</html>