Passing parameters in an Angular.js Controller to a Resource
<script> | |
// in the html page | |
angular.module('config', []).constant('APIKEY',''5250738f97ce29c219000011''); | |
</script> | |
myApp.controller('JobsCtrl', ['$scope', 'Jobs', 'APIKEY', function($scope, Jobs, apiKey) { | |
var promise = Jobs(apiKey).query().$promise; | |
// do more awesome programming | |
} | |
myApp.factory('Jobs', ['$resource', function ($resource) { | |
return function(apiKey){ | |
return $resource('/someurl/:id', {id:'@id'}, { | |
query: { method: 'GET', headers: {'Authorization': apiKey} } | |
}); | |
} | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
Very helpful thanks.