title: Pushing or Unshifting into the transformRequest array of $http (non-global)
body: <p>See the accepted answer to <a href="https://stackoverflow.com/questions/12190166/angularjs-any-way-for-http-post-to-send-request-parameters-instead-of-json">here</a> for a pretty good explanation on the transFormRequest function/array.</p>
  
  <p>In the answer's last example:</p>
  
  <pre><code>var transform = function(data){
      return $.param(data);
  }
  
  $http.post("/foo/bar", requestData, {
      headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
      transformRequest: transform
  }).success(function(responseData) {
      //do stuff with response
  });
  </code></pre>
  
  <p>However, the problem with this is that <code>transformRequest: transform</code> overwrites the array of functions that Angular has pre-built.</p>
  
  <p>From the Angular <a href="http://docs.angularjs.org/api/ng.$http" rel="nofollow noreferrer">docs</a>:</p>
  
  <blockquote>
    <blockquote>
      <p>To globally augment or override the default transforms, modify the $httpProvider.defaults.transformRequest and $httpProvider.defaults.transformResponse properties. These properties are by default an array of transform functions, which allows you to push or unshift a new transformation function into the transformation chain. You can also decide to completely override any default transformations by assigning your transformation functions to these properties directly without the array wrapper. These defaults are again available on the $http factory at run-time, which may be useful if you have run-time services you wish to be involved in your transformations.</p>
      
      <p>Similarly, to locally override the request/response transforms, augment the transformRequest and/or transformResponse properties of the configuration object passed into $http.</p>
    </blockquote>
  </blockquote>
  
  <p>If I wanted to apply my transform function globally, I would do</p>
  
  <pre><code>$httpProvider.defaults.transformRequest.unshift(myFunction)
  </code></pre>
  
  <p>or</p>
  
  <pre><code>$httpProvider.defaults.transformRequest.push(myFunction)
  </code></pre>
  
  <p><strong>My question</strong><br>
  Instead of erasing the entire array of transform request functions, how to you push another transform function to a call, not globally?</p>