MCPcopy Create free account
hub / github.com/angular-ui/ui-grid / $HttpParamSerializerProvider

Function $HttpParamSerializerProvider

lib/test/angular/1.6.7/angular.js:11257–11292  ·  view source on GitHub ↗

@this

()

Source from the content-addressed store, hash-verified

11255
11256/** @this */
11257function $HttpParamSerializerProvider() {
11258 /**
11259 * @ngdoc service
11260 * @name $httpParamSerializer
11261 * @description
11262 *
11263 * Default {@link $http `$http`} params serializer that converts objects to strings
11264 * according to the following rules:
11265 *
11266 * * `{'foo': 'bar'}` results in `foo=bar`
11267 * * `{'foo': Date.now()}` results in `foo=2015-04-01T09%3A50%3A49.262Z` (`toISOString()` and encoded representation of a Date object)
11268 * * `{'foo': ['bar', 'baz']}` results in `foo=bar&foo=baz` (repeated key for each array element)
11269 * * `{'foo': {'bar':'baz'}}` results in `foo=%7B%22bar%22%3A%22baz%22%7D` (stringified and encoded representation of an object)
11270 *
11271 * Note that serializer will sort the request parameters alphabetically.
11272 * */
11273
11274 this.$get = function() {
11275 return function ngParamSerializer(params) {
11276 if (!params) return '';
11277 var parts = [];
11278 forEachSorted(params, function(value, key) {
11279 if (value === null || isUndefined(value) || isFunction(value)) return;
11280 if (isArray(value)) {
11281 forEach(value, function(v) {
11282 parts.push(encodeUriQuery(key) + '=' + encodeUriQuery(serializeValue(v)));
11283 });
11284 } else {
11285 parts.push(encodeUriQuery(key) + '=' + encodeUriQuery(serializeValue(value)));
11286 }
11287 });
11288
11289 return parts.join('&');
11290 };
11291 };
11292}
11293
11294/** @this */
11295function $HttpParamSerializerJQLikeProvider() {

Callers

nothing calls this directly

Calls 7

forEachSortedFunction · 0.70
isUndefinedFunction · 0.70
isFunctionFunction · 0.70
forEachFunction · 0.70
encodeUriQueryFunction · 0.70
serializeValueFunction · 0.70
isArrayFunction · 0.50

Tested by

no test coverage detected