Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

improve(docs): add $location.search() example #7030

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/ng/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,16 @@ LocationHashbangInHtml5Url.prototype =
* comma-separated value. If `paramValue` is `null`, the parameter will be deleted.
*
* @return {string} search
*
* @example If you want to get a specific value of the search, make sure you do not pass any arguments.
*
* <example>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use the <example> doc tag for this, github flavoured markdown is just fine.

// This will return the `$location` object:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unclear and doesn't really tie well with your example.

Returning the $location object is for enabling chaining calls. What the function actually does is changes the query parameters, or prepares to in the next update.

$location.search('what-you-want')

// This will return give you the value you actually want:
$location.search()['what-you-want']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When called as a getter (IE not setting any particular values), it will return the current set of key/value pairs representing the search query.

This example does not make this clear, and should be improved.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you can turn this into a working example which should actually render markup to illustrate what it's doing, then by all means, use the <example> tag. But, for simple code examples, it's not needed.

* </example>
*/
search: function(search, paramValue) {
switch (arguments.length) {
Expand Down