Case :
I have a request interceptor implemented that works as a service. The functionality of its is to supply every request with authentication token.
myApp.factory('httpRequestInterceptor', function () {
return {
request: function (config) {
config.headers['Auth-Token'] = 'SomeValue';
return config;
}
};
});
myApp.config(function ($httpProvider) {
$httpProvider.interceptors.push('httpRequestInterceptor');
});
Now every time I make some $http requests, it adds to the reqest header and every thing works just perfect.
Problem :
I am making $http calls from a controller. Now the authentication token will be passed to me from calling application which invokes this UI page. I want to have provision where I can catch the incoming parameters from the invoking application and use the passed parameter to the interceptor service. In short I want to pass a value from my controller to the 'httpRequestInterceptor'.
Note that I don't have any control over invoking application.
Please let me know how do I achieve this.