MCPcopy Index your code
hub / github.com/angular-ui/ui-grid / $HttpParamSerializerProvider

Function $HttpParamSerializerProvider

lib/test/angular/1.5.0/angular.js:10016–10051  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10014
10015
10016function $HttpParamSerializerProvider() {
10017 /**
10018 * @ngdoc service
10019 * @name $httpParamSerializer
10020 * @description
10021 *
10022 * Default {@link $http `$http`} params serializer that converts objects to strings
10023 * according to the following rules:
10024 *
10025 * * `{'foo': 'bar'}` results in `foo=bar`
10026 * * `{'foo': Date.now()}` results in `foo=2015-04-01T09%3A50%3A49.262Z` (`toISOString()` and encoded representation of a Date object)
10027 * * `{'foo': ['bar', 'baz']}` results in `foo=bar&foo=baz` (repeated key for each array element)
10028 * * `{'foo': {'bar':'baz'}}` results in `foo=%7B%22bar%22%3A%22baz%22%7D"` (stringified and encoded representation of an object)
10029 *
10030 * Note that serializer will sort the request parameters alphabetically.
10031 * */
10032
10033 this.$get = function() {
10034 return function ngParamSerializer(params) {
10035 if (!params) return '';
10036 var parts = [];
10037 forEachSorted(params, function(value, key) {
10038 if (value === null || isUndefined(value)) return;
10039 if (isArray(value)) {
10040 forEach(value, function(v, k) {
10041 parts.push(encodeUriQuery(key) + '=' + encodeUriQuery(serializeValue(v)));
10042 });
10043 } else {
10044 parts.push(encodeUriQuery(key) + '=' + encodeUriQuery(serializeValue(value)));
10045 }
10046 });
10047
10048 return parts.join('&');
10049 };
10050 };
10051}
10052
10053function $HttpParamSerializerJQLikeProvider() {
10054 /**

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected