title: How to pass headers on the fly to $resource for angularjs
body: <p>Right now, the only way that I know for setting tokens in headers dynamically for an angularjs call is via <code>$http</code> like so:</p>
  
  <pre><code>return $http.get({
    url: 'https://my.backend.com/api/jokes',
    params: {
      'jokeId': '5',
    },
    headers: {
      'Authorization': 'Bearer '+ $scope.myOAuthToken
    }
  });
  </code></pre>
  
  <p>But I want to figure out how to pass this via $resource, here's some pseudo-code that doesn't work:</p>
  
  <pre><code>...
  .factory('myFactory',
    ['$resource',
      function($resource){
        return {
          jokes: $resource('https://my.backend.com/api/jokes', null, {
            query: {
              method: 'GET'
            }
          })
        };
      }
    ]
  );
  ...
  return myFactory.jokes.query({
    'jokeId': '5',
    'headers': {
      'Authorization': 'Bearer '+ $scope.myOAuthToken
    }
  });
  </code></pre>
  
  <p>How can I  pass headers on the fly to $resource for angularjs?</p>