docs($http): add a note about modifying data in transformRequest
Closes #12468
This commit is contained in:
@@ -550,6 +550,15 @@ function $HttpProvider() {
|
||||
* the transformed value (`function(data, headersGetter, status)`) or an array of such transformation functions,
|
||||
* which allows you to `push` or `unshift` a new transformation function into the transformation chain.
|
||||
*
|
||||
* <div class="alert alert-warning">
|
||||
* **Note:** Angular does not make a copy of the `data` parameter before it is passed into the `transformRequest` pipeline.
|
||||
* That means changes to the properties of `data` are not local to the transform function (since Javascript passes objects by reference).
|
||||
* For example, when calling `$http.get(url, $scope.myObject)`, modifications to the object's properties in a transformRequest
|
||||
* function will be reflected on the scope and in any templates where the object is data-bound.
|
||||
* To prevent his, transform functions should have no side-effects.
|
||||
* If you need to modify properties, it is recommended to make a copy of the data, or create new object to return.
|
||||
* </div>
|
||||
*
|
||||
* ### Default Transformations
|
||||
*
|
||||
* The `$httpProvider` provider and `$http` service expose `defaults.transformRequest` and
|
||||
|
||||
Reference in New Issue
Block a user