我有這個登錄服務:如何使用angularjs從登錄服務獲取全局特定url的標頭?
var url = GetHostUrl.cvmUrl+'/WSUser/users/login';
$http({
method : 'POST',
url : url,
data : $.param({
username:$scope.user_name,
password:$scope.pass,
domain: GetHostUrl.cvmServerUpdated
}),
headers : {'Content-Type': 'application/x-www-form-urlencoded'}
})
.success(function(data){
$localstorage.authtoken = data.authtoken;
}
不得不在頭傳遞$localstorage.authtoken
全球範圍內爲特定的URL。
我已經爲所有url設置了標題屬性。我必須爲標題添加一個公共屬性到特定的URL – Idris
,因此通過覆蓋默認值常見服務並進行** http **調用來相應地更改標題。 您的LoginService將擴展HTTPService並使用HTTPService.call方法進行http調用 –