E
E
evgemiil2016-09-20 14:28:46
JavaScript
evgemiil, 2016-09-20 14:28:46

How to fit the declination code to the counter?

there is a code for declining words from numbers, but I can’t figure out how to make it declinate from counter numbers, and output

<!DOCTYPE html>
<html>

  <head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
    <script data-require="[email protected]" data-semver="1.5.8" src="https://code.angularjs.org/1.5.8/angular.js"></script>
    <link rel="stylesheet" href="style.css" />
    <script src="script.js"></script>
<script type="text/javascript">
    angular.module("CounterApp", []).controller("CounterController1", function($scope) { 
$scope.a = 0;
 $scope.b = 0;
 $scope.c = 0;
$scope.decrementA = function() { 
if ($scope.a > 0) $scope.a--;
}
$scope.decrementB = function() { 
if ($scope.b > 0) $scope.b--;
}
$scope.decrementC = function() { 
if ($scope.c > 0) $scope.c--;
}})
        var Lang = {};

        Lang.GetNoun = function(number, one, two, five) {
            number = Math.abs(number);
            number %= 100;
            if (number >= 5 && number <= 20) {
                return five;
            }
            number %= 10;
            if (number == 1) {
                return one;
            }
            if (number >= 2 && number <= 4) {
                return two;
            }
            return five;
        }

        function showText(n) {
            
            var text = n + " " +
            
            Lang.GetNoun(n, "штука", "штуки", "штук");
            ..........
        }
    </script>
  </head>

  <body>
    <div ng-app="CounterApp" ng-controller="CounterController1">
      <div class="counter1">
        <button class="butcount1" ng-click="decrementA()">-</button> {{a}}
        <button ng-click="a = a + 1">+</button>
      </div>
        <div class="counter2">
        <button ng-click="decrementB()">-</button> {{b}}
        <button ng-click="b = b + 1">+</button>
      </div>
      <div class="counter3">
        <button ng-click="decrementC()">-</button> {{c}}
        <button ng-click="c = c + 1">+</button>
      </div>
  <div class="sum">Итого: {{ a + b + c }}</div>
</div>
  </body>

</html>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2016-09-20
@SPAHI4

https://www.npmjs.com/search?q=plural

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question