आप कोणीय 1.0.x के लिए डिफ़ॉल्ट हेडर का उपयोग कर सकते हैं:
$http.defaults.headers.common['Authentication'] = 'authentication';
या कोणीय 1.1.x + के लिए अनुरोध इंटरसेप्टर:
myapp.factory('httpRequestInterceptor', function() {
return {
request: function (config) {
// use this to destroying other existing headers
config.headers = {'Authentication':'authentication'}
// use this to prevent destroying other existing headers
// config.headers['Authorization'] = 'authentication';
return config;
}
};
});
myapp.config(function ($httpProvider) {
$httpProvider.interceptors.push('httpRequestInterceptor');
});
के बाद से कारखानों/सेवाओं एकमात्र, इस कर रहे हैं तब तक काम करता है जब तक सेवा को तत्काल नहीं किया जाता है, आपको अपने 'प्रमाणीकरण' मूल्य को गतिशील रूप से बदलने की आवश्यकता नहीं होती है।
स्रोत
2013-11-29 23:08:42
क्या आप मुख्य नामों को सामान्य करके अपना मतलब बता सकते हैं? – Webnet
हेडर() विधि का उपयोग कर हेडर प्राप्त करते समय, कुंजी "ऑथ-टोकन" कम हो जाती है और "ऑथ-टोकन" बन जाती है। जो भ्रमित है। – lucassp
@lucassp यह हो सकता है - http://stackoverflow.com/questions/5258977/are-http-headers-case- संवेदनशील – KrIsHnA