title: Error on $q Even though it is injected in controller
body: <p>I'm getting an error (it doesn't give me an error description for some reason) whenever I hit the following line in my function:</p>
  
  <pre><code> var deferred = $q.defer();
  </code></pre>
  
  <p>Function is called with this:</p>
  
  <pre><code>        var promise = saveAccessPermissions($scope.form.permissions, $scope.form);
      promise.then(function () {
          alert('items saved');
      })
  </code></pre>
  
  <p>Here is entire function, but it never gets past the <code>$q</code>.</p>
  
  <pre><code>function saveAccessPermissions(permissions, form) {
  
  var deferred = $q.defer();
  var permissionCount = 0;
  function saveAccess() {
      form.AccessListItemPropertyId = permissions[permissionCount].AccessListItemPropertyId;
      PermissionsService.insertEmployeeAccess(form)
          .then(function () {
              permissionCount++;
              if (permissionCount &lt; permissions.length) {
                  return saveAccess();
              }
              else {
                  deferred.resolve();
              }
          }).error(function (reason) {
              alert(reason);
          });
  }
  </code></pre>
  
  <p>}</p>
  
  <p>This is the way I have always used it, but it is erroring out on that line.  I have injected it into my controller:</p>
  
  <pre><code> angular.module('myModule').controller('PermissionsCtrl', PermissionsCtrl);
  PermissionsCtrl.$inject = ['$scope', 'PermissionsService', '$filter', '$q', '$http'];
  function PermissionsCtrl($scope, PermissionsService, $filter, $q, $http) {
  </code></pre>
  
  <p>I'm not sure what I am missing.  Any assistance is greatly appreciated!</p>