docs($location): improve $location.search() docs

Closes #7030
This commit is contained in:
Igor Minar
2014-04-07 16:09:04 -07:00
parent ea72e5f881
commit e987efd4c0

View File

@@ -399,15 +399,37 @@ LocationHashbangInHtml5Url.prototype =
*
* 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. Hash object may contain an array of values, which will be decoded as duplicates in
* the url.
* hash object.
*
* @param {(string|Array<string>)=} paramValue If `search` is a string, then `paramValue` will override only a
* single search parameter. If `paramValue` is an array, it will set the parameter as a
* comma-separated value. If `paramValue` is `null`, the parameter will be deleted.
* When called with a single argument the method acts as a setter, setting the `search` component
* of `$location` to the specified value.
*
* @return {string} search
* 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>)=} 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.
*
* @return {Object} If called with no arguments returns the parsed `search` object. If called with
* one or more arguments returns `$location` object itself.
*/
search: function(search, paramValue) {
switch (arguments.length) {