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

Function $HttpParamSerializerProvider

lib/test/angular/1.8.0/angular.js:11961–11996  ·  view source on GitHub ↗

@this

()

Source from the content-addressed store, hash-verified

11959
11960/** @this */
11961function $HttpParamSerializerProvider() {
11962 /**
11963 * @ngdoc service
11964 * @name $httpParamSerializer
11965 * @description
11966 *
11967 * Default {@link $http `$http`} params serializer that converts objects to strings
11968 * according to the following rules:
11969 *
11970 * * `{'foo': 'bar'}` results in `foo=bar`
11971 * * `{'foo': Date.now()}` results in `foo=2015-04-01T09%3A50%3A49.262Z` (`toISOString()` and encoded representation of a Date object)
11972 * * `{'foo': ['bar', 'baz']}` results in `foo=bar&foo=baz` (repeated key for each array element)
11973 * * `{'foo': {'bar':'baz'}}` results in `foo=%7B%22bar%22%3A%22baz%22%7D` (stringified and encoded representation of an object)
11974 *
11975 * Note that serializer will sort the request parameters alphabetically.
11976 */
11977
11978 this.$get = function() {
11979 return function ngParamSerializer(params) {
11980 if (!params) return '';
11981 var parts = [];
11982 forEachSorted(params, function(value, key) {
11983 if (value === null || isUndefined(value) || isFunction(value)) return;
11984 if (isArray(value)) {
11985 forEach(value, function(v) {
11986 parts.push(encodeUriQuery(key) + '=' + encodeUriQuery(serializeValue(v)));
11987 });
11988 } else {
11989 parts.push(encodeUriQuery(key) + '=' + encodeUriQuery(serializeValue(value)));
11990 }
11991 });
11992
11993 return parts.join('&');
11994 };
11995 };
11996}
11997
11998/** @this */
11999function $HttpParamSerializerJQLikeProvider() {

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected