docs($location): add examples for some methods

Closes #9754
This commit is contained in:
Shang Heng (Shawn) Wei
2014-11-22 13:13:55 -08:00
committed by Brian Ford
parent a3d79775e1
commit 3be6835e0f

View File

@@ -327,6 +327,13 @@ var locationPrototype = {
* Return full url representation with all segments encoded according to rules specified in
* [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt).
*
*
* ```js
* // given url http://example.com/#/some/path?foo=bar&baz=xoxo
* var absUrl = $location.absUrl();
* // => "http://example.com/#/some/path?foo=bar&baz=xoxo"
* ```
*
* @return {string} full url
*/
absUrl: locationGetter('$$absUrl'),
@@ -342,6 +349,13 @@ var locationPrototype = {
*
* Change path, search and hash, when called with parameter and return `$location`.
*
*
* ```js
* // given url http://example.com/#/some/path?foo=bar&baz=xoxo
* var url = $location.url();
* // => "/some/path?foo=bar&baz=xoxo"
* ```
*
* @param {string=} url New url without base prefix (e.g. `/path?a=b#hash`)
* @return {string} url
*/
@@ -366,6 +380,13 @@ var locationPrototype = {
*
* Return protocol of current url.
*
*
* ```js
* // given url http://example.com/#/some/path?foo=bar&baz=xoxo
* var protocol = $location.protocol();
* // => "http"
* ```
*
* @return {string} protocol of current url
*/
protocol: locationGetter('$$protocol'),
@@ -379,6 +400,13 @@ var locationPrototype = {
*
* Return host of current url.
*
*
* ```js
* // given url http://example.com/#/some/path?foo=bar&baz=xoxo
* var host = $location.host();
* // => "example.com"
* ```
*
* @return {string} host of current url.
*/
host: locationGetter('$$host'),
@@ -392,6 +420,13 @@ var locationPrototype = {
*
* Return port of current url.
*
*
* ```js
* // given url http://example.com/#/some/path?foo=bar&baz=xoxo
* var port = $location.port();
* // => 80
* ```
*
* @return {Number} port
*/
port: locationGetter('$$port'),
@@ -410,6 +445,13 @@ var locationPrototype = {
* Note: Path should always begin with forward slash (/), this method will add the forward slash
* if it is missing.
*
*
* ```js
* // given url http://example.com/#/some/path?foo=bar&baz=xoxo
* var path = $location.path();
* // => "/some/path"
* ```
*
* @param {(string|number)=} path New path
* @return {string} path
*/
@@ -435,10 +477,9 @@ var locationPrototype = {
* var searchObject = $location.search();
* // => {foo: 'bar', baz: 'xoxo'}
*
*
* // set foo to 'yipee'
* $location.search('foo', 'yipee');
* // => $location
* // $location.search() => {foo: 'yipee', baz: 'xoxo'}
* ```
*
* @param {string|Object.<string>|Object.<Array.<string>>} search New search params - string or
@@ -508,6 +549,13 @@ var locationPrototype = {
*
* Change hash fragment when called with parameter and return `$location`.
*
*
* ```js
* // given url http://example.com/some/path?foo=bar&baz=xoxo#hashValue
* var hash = $location.hash();
* // => "hashValue"
* ```
*
* @param {(string|number)=} hash New hash fragment
* @return {string} hash
*/