title: Angular Infinite $digest Loop
body: <p>I am working on a site where you can search a food, and see if its a fruit, a vegetable, or neither (because I'm bored). I decided to use Angular, even though I'm pretty new to it.
  I started getting this error: <a href="https://docs.angularjs.org/error/$rootScope/infdig">$rootScope:infdig
  Infinite $digest Loop</a></p>
  
  <p>That's may or may not be the exact phrasing or the error, because the page lags out so much, I can't open the Javascript console. </p>
  
  <p>This my result view controller:</p>
  
  <pre><code>app.controller('resultController', ['$scope', '$routeParams', '$http',
      function($scope, $routeParams, $http) {
          $scope.result = $routeParams.query;
  
          $scope.whatIsIt = function() {
              $http.get('json/foods.json').success(function(data) {
                  var lists = JSON.parse(data);
                  var itIsA = 'uuggghhhhh';
  
                  if (lists['fruit'].contains($scope.result)) {
                      itIsA = 'fruit';
                  } else if (lists['vegetable'].contains($scope.result)) {
                      itIsA = 'vegetable';
                  }
              });
          }
      }]);
  </code></pre>
  
  <p>Heres my app module:</p>
  
  <pre><code>var app = angular.module('fruitOrNot', [
      'ngRoute'
  ]);
  
  app.config(['$routeProvider' ,
      function($routeProvider) {
          $routeProvider.when('/', {
              templateUrl: 'layouts/fruit-search.html',
              controller: 'searchController'
          }).when('/:query', {
              templateUrl: 'layouts/result.html',
              controller: 'resultController'
          });
      }]);
  </code></pre>
  
  <p>And here is layouts/result.html:</p>
  
  <pre><code>&lt;h1&gt;{{ result }}&lt;/h1&gt;
  &lt;p&gt;{{ result }} is a {{ whatIsIt() }}&lt;/p&gt;
  </code></pre>
  
  <p>So I am wondering what could be causing that <code>$digest</code> loop error, or how to find out, because I can't use the console. Thanks!</p>
  
  <p>The whole project is <a href="https://github.com/INOVA-Technology/isitafruitoravegetable.com">here</a> on Github as well.</p>