So I have the following controller where I inject a constant, APIKEY.
myApp.controller('JobsCtrl', ['$scope', 'Jobs', 'APIKEY', function($scope, Jobs, apiKey) {
var promise = Jobs.query().$promise;
// do more awesome programming
}
I want to pass the apiKey to the following service but can't figure out for the life of me how to do it.
myApp.factory('Jobs', ['$resource', function ($resource) {
return $resource('/someurl/:id', {id:'@id'}, {
query: { method: 'GET', headers: {'Authorization': apiKey} }
});
}]);
Thanks!
$resource