title: angularjs: add show less button logic - fiddle included
body: <p>I found a fiddle that show how to add a button to show more records using a angularJS, it is pretty neat. I am trying to add a show less button, but I am not getting right the formula. I added and opposite of what the show more code does, but I am missing a pieces. I would like to get help in learning how to accomplish this. </p>
  
  <p><strong>fiddle:</strong></p>
  
  <p><a href="http://jsfiddle.net/s4zhaq62/" rel="nofollow">demo</a></p>
  
  <p><strong>code snippet:</strong></p>
  
  <pre><code>     //show more functionality
          var pagesShown = 1;
          var pageSize = 3;
  
          $scope.paginationLimit = function(data) {
              return pageSize * pagesShown;
          };
          $scope.hasMoreItemsToShow = function() {
              return pagesShown &lt; ($scope.datalists.length / pageSize);
          };
          $scope.showMoreItems = function() {
              pagesShown = pagesShown + 1;       
          };
  
          $scope.hasLessItemsToShow = function() {
              return pagesShown &gt;= ($scope.datalists.length / pageSize);
          };
          $scope.showLessItems = function() {
              pagesShown = pagesShown - 1;       
          };
  </code></pre>
  
  <p>Thank you very much. </p>