title: AngularJS mathematical calculations with ng-model, ng-click buttons, outputting the results in web app
body: <p>I'm starting with AngularJS, learning it bit by bit. For several days now, I am trying to understand how to calculate between ng-models (scopes) in a web-application.</p>
  
  <p>Here is what I am trying to solve as an example: <a href="http://plnkr.co/edit/M2b7GNcbgM30phLXT8pU" rel="nofollow">http://plnkr.co/edit/M2b7GNcbgM30phLXT8pU</a> There, if I buy a stack (one click on the 1st button) of papers, then I sell 2 sheets (2 clicks on the 2nd button), the result should show "You have 1.998 stacks"</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>First we buy a stack of papers…
  &lt;button input type="button" class="btn" name="StackOfPaper" ng-model="StackOfPaper" ng-click="StackOfPaper = StackOfPaper + 1" ng-init="StackOfPaper=0"&gt;Buy a stack of papers&lt;br&gt;(total bought: {{StackOfPaper|number:3}})&lt;/button&gt;&lt;br&gt;&lt;br&gt;
  
  …then we sell individual paper sheets…
  &lt;button input type="button" class="btn" name="PaperSheet" ng-model="PaperSheet" ng-click="PaperSheet = PaperSheet + 1" ng-init="PaperSheet=0"&gt;Sell a paper sheet&lt;br&gt;(total sold: {{PaperSheet}})&lt;/button&gt;&lt;br&gt;&lt;br&gt;
  
  …get the number of sheets left in the stacks&lt;br&gt; 
  You have {{whatsleft|number:3}} stacks
  </code></pre>
  
  <p><strong>JS</strong></p>
  
  <pre><code>var app = angular.module('paper', []);
  
  $scope.$watch(function() {
      return Math.floor($scope.StackOfPaper*1000 - $scope.PaperSheet);
  }, function(SheetsLeft) {
      $scope.SheetsLeft = whatsleft;
  });
  </code></pre>
  
  <p>Could you please help me, or suggest a good tutorial for this, I have tried all the combinations other people used, read tons of how-tos, but nothing worked for me. Maybe I am omitting some small things there?</p>
  
  <p>Or is there a better way of doing the said things?
  Thank you for the explanation.</p>