@ngdoc method
@name $location#search

@description
This method is getter / setter.

Return search part (as object) of current url when called without any parameter.

Change search part when called with parameter and return `$location`.


```js
// given url http://example.com/#/some/path?foo=bar&baz=xoxo
var searchObject = $location.search();
// => {foo: 'bar', baz: 'xoxo'}


// set foo to 'yipee'
$location.search('foo', 'yipee');
// => $location
```

@param {string|Object.<string>|Object.<Array.<string>>} search New search params - string or
hash object.

When called with a single argument the method acts as a setter, setting the `search` component
of `$location` to the specified value.

If the argument is a hash object containing an array of values, these values will be encoded
as duplicate search parameters in the url.

@param {(string|Array<string>|boolean)=} paramValue If `search` is a string, then `paramValue`
will override only a single search property.

If `paramValue` is an array, it will override the property of the `search` component of
`$location` specified via the first argument.

If `paramValue` is `null`, the property specified via the first argument will be deleted.

If `paramValue` is `true`, the property specified via the first argument will be added with no
value nor trailing equal sign.

@return {Object} If called with no arguments returns the parsed `search` object. If called with
one or more arguments returns `$location` object itself.
function(search, paramValue) {
    switch (arguments.length) {
      case 0:
        return this.$$search;
      case 1:
        if (isString(search)) {
          this.$$search = parseKeyValue(search);
        } else if (isObject(search)) {
          // remove object undefined or null properties
          forEach(search, function(value, key) {
            if (value == null) delete search[key];
          });

          this.$$search = search;
        } else {
          throw $locationMinErr('isrcharg',
              'The first argument of the `$location#search()` call must be a string or an object.');
        }
        break;
      default:
        if (isUndefined(paramValue) || paramValue === null) {
          delete this.$$search[search];
        } else {
          this.$$search[search] = paramValue;
        }
    }

    this.$$compose();
    return this;
  }