title: how to pass headers in http call in angularjs
body: <p>I am developing mobile application in cordova/phonegap. I am using angularJS for front-end. I am calling services which required 'API-KEY' attribute as header in post request.</p>
  
  <p>I show some documentations, and tried with those way. but not worked.</p>
  
  <pre><code>postServiceDataWithHeader: function (url, data) {
              var deferred = $q.defer();
              var req = {
                  method: 'POST',
                  url: url,
                  data: JSON.stringify(data),
                  headers: {
                      'user-Token': $rootScope.user.APIKEY,
                      'content-Type': 'Application/Json'
                  }
              }
              $http(req).success(function (data) {
                  deferred.resolve(data);
              }).error(function (data, status, headers, config) {
                  alert("Server failed to save data");
                  deferred.reject(status);
              });
              return deferred.promise;
          } 
  </code></pre>
  
  <p>I tried to add headers in call with,</p>
  
  <pre><code>JodoModule.config(function ($routeProvider, $httpProvider) {
      $httpProvider.defaults.headers.post['user-Token'] = 'finding???';
      $httpProvider.defaults.headers.post['Content-Type'] = 'application/json; charset=utf-8';
  });
  </code></pre>
  
  <p>and second approach was,</p>
  
  <pre><code>JodoModule.run(['$rootScope', '$http', function ($rootScope, $http) {    
      $http.defaults.headers.common.Authorization = 'Basic YmVlcDpib29w';    
  }]);
  </code></pre>
  
  <p>I am able to call services, but on server side, I am not getting header values, even in fiddler also headers are not passed.</p>
  
  <p>What is the reason ? Do I need to add anything else in code for passing headers for each POST request. ?</p>