Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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} }
});
}
}]);
@adachenski

This comment has been minimized.

Copy link

@adachenski adachenski commented Jan 9, 2017

Very helpful thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment