title: How to check if a returned object is empty or populated in AngularJS
body: <p>I am working on a Sample Quiz application. So my code using Web Api's in C# makes a called to the database and gets a quiz that matches the id that was passed. And the data is returned in a JSON format. </p>
  
  <p>If a quiz matching the id is found, this is the data that is passed:</p>
  
  <pre><code>{"Id":2,"Options":[{"id":1,"qid":2,"option":"50 mi/hr","result":false},{"id":2,"qid":2,"option":"756 mi/hr","result":false},{"id":3,"qid":2,"option":"765 mi/hr","result":true},{"id":4,"qid":2,"option":"630 mi/hr","result":false}],"Question":"What is the speed of sound through air "}
  
  Quiz: id, Options[],Question.
  </code></pre>
  
  <p>If a quiz is not found, it returns an empty output:</p>
  
  <pre><code>{"Id":0,"Options":[],"Question":null}
  </code></pre>
  
  <p>Now in AngularJS, I am trying to check if what is returned is equal to the empty output. This is the code i wrote, but its not working:</p>
  
  <pre><code>SimpleQuiz.factory('Quiz', function ($resource) {
      return $resource('/api/Quiz/:id', { id: '@id' }, { update: { method: 'PUT' } 
  });
  
  $scope.startQuiz = function ()
  {
      // and id is passed into the Quiz.get function
      // and the returned output is stored in $scope.item
      $scope.item = Quiz.get({ id: $scope.quizid });
  
      var sampleitem = $scope.item
  
      // this is the part that isn't working
      if (angular.equals(smpleitem,emptyQuizObject))
      {
          // redirect if they are the same
          $location.path('/start');
      }
      else
      {
          // output to the screen
          $scope.item = $scope.item; // this works
      }
  }// end start quiz
  
  var emptyQuizObject = {"Id": 0, "Options": [], "Question": null };
  $scope.startQuiz(); // start the quiz
  </code></pre>
  
  <p>C# code for the Web Api:</p>
  
  <pre><code>public class QuizController : ApiController
  {
      public QuizQuestion Get(int id)
      {
          QuizQuestion question = Models.DbStoredProcModel.GetQuiz.GetaQuiz(id);
          return question;
      }
  }
  </code></pre>