我对角度很新。我正在实施基于令牌的授权。后端开发人员希望我通过标头发送令牌 以这种格式{auth_token:whatever}。我的问题是我的标题配置是否遵循正确的格式。
angular.module('sampleModule').factory('httpRequestInterceptor',
['$localStorage', function($localStorage) //I'm using the ng-storage library
{
return {
request: function($config) {
if( $localStorage.accessToken )
{
$config.headers['auth_token'] = $localStorage.accessToken; //is this following my backend developer's format {auth_token: whatever}?
}
return $config;
}
};
}]);