title: Cannot read property length angularjs
body: <p>I have the following piece of code in an angular app that i generated using yeoman</p>
  
  <pre><code>'use strict';
  
  function CoffeeListCtrl($scope, $http) {
    $http.get('data/coffee.json').success(function(data) {
      $scope.coffees = data;
    });
      $scope.orderProp = 'name';
      $scope.orderType = '';
  
      $scope.goTo = function (path) {
          $location.path(path);
      }
  
  $scope.showNresults = function (n) {
          if (n==-1) {
              return $scope.coffees.length;
          } else { 
              return n;
          }
          //REVIEW: code optimization .. shrink version
          // message = ('Stephen' === name) ? "Welcome back Stephen" : "Welcome " + name;
    }
  
   $scope.numberOfPages=function(itemsPerPage){
          if (itemsPerPage == -1) itemsPerPage=$scope.coffees.length;
      return Math.ceil($scope.coffees.length/itemsPerPage);              
    }
  }
  </code></pre>
  
  <p>Any idea why I might be getting the following <a href="http://i.imgur.com/2ulmaTI.png" rel="nofollow">console output</a></p>
  
  <p><strong>Update</strong>
  Have the following html snippet code: </p>
  
  <pre><code>&lt;div class="row-fluid"&gt; 
      &lt;ul class="coffees"&gt;
        &lt;li class="span4 coffeeitem" ng-repeat="coffee in (filteredItems = (coffees | filter:query | orderBy:orderProp | filter:orderType | startFrom: (currentPage*resultspp)-resultspp | limitTo: showNresults(resultspp)))"&gt;
          &lt;a href="#/coffees/{{coffee.id}}"&gt;{{coffee.name}}&lt;/a&gt;
          &lt;p&gt;{{coffee.basicInfo}}&lt;/p&gt;
          &lt;button class="coffeebutton" type="button"&gt;Add to list&lt;/button&gt;
        &lt;/li&gt;
        &lt;p ng-show="(coffees | filter:query).length == 0" id="message"&gt;No coffee found, please refine your search&lt;/p&gt;
      &lt;/ul&gt;
    &lt;/div&gt;
  </code></pre>
  
  <p>And have nailed down to the following that is causing me the circular dependency error <code>startFrom: (currentPage*resultspp)-resultspp | limitTo: showNresults(resultspp)</code></p>