I am new to angular and trying to make an API call with access-token. Below is the service that i am using for this API call.
(function(){
angular.module('app')
.factory('Student',Student);
Student.$inject = ['$resource','$rootScope'];
function Student($resource, $rootScope){
var URL = 'myUrl';
var details = $resource(URL + ':id/',{
id:'@id',
},{ }
);
return {
details: details,
};
}
})();
Inside the controller
Student.details.get(function(data){
console.log(data);
});
My question is, how should i add an access-token with the header of this request? I am having the token in $rootScope. Descriptions shown here and here doesn't works for me.