forked from angular/code.angularjs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular.service.$location.html
69 lines (67 loc) · 2.42 KB
/
angular.service.$location.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<h1>angular.service.$location</h1>
<fieldset class="workInProgress"><legend>Work in Progress</legend>
This page is currently being revised. It might be incomplete or contain inaccuracies.</fieldset>
<h2>Description</h2>
<p>Parses the browser location url and makes it available to your application.
Any changes to the url are reflected into $location service and changes to
$location are reflected to url.
Notice that using browser's forward/back buttons changes the $location.</p><h2>Dependencies</h2>
<ul class="dependencies"><li>$browser</li>
</ul>
<h2>Methods</h2>
<ul class="methods"><li><h3>update(href)</h3>
<p>Update location object
Does not immediately update the browser
Browser is updated at the end of $eval()</p><h4>Parameters</h4>
<ul class="parameters"><li><code ng:non-bindable="">href – {(string|Object)} – </code>
Full href as a string or object with properties</li>
</ul>
<h4>Example</h4>
<div ng:non-bindable=""><pre class="brush: js; html-script: true;">scope.$location.update('http://www.angularjs.org/path#hash?search=x');
scope.$location.update({host: 'www.google.com', protocol: 'https'});
scope.$location.update({hashPath: '/path', hashSearch: {a: 'b', x: true}});</pre>
</div>
</li>
<li><h3>updateHash(path, search)</h3>
<p>Update location hash part</p><h4>Parameters</h4>
<ul class="parameters"><li><code ng:non-bindable="">path – {(string|Object)} – </code>
A hashPath or hashSearch object</li>
<li><code ng:non-bindable="">search<i>(optional)</i> – {Object} – </code>
A hashSearch object</li>
</ul>
<h4>Example</h4>
<div ng:non-bindable=""><pre class="brush: js; html-script: true;">scope.$location.updateHash('/hp')
==> update({hashPath: '/hp'})
scope.$location.updateHash({a: true, b: 'val'})
==> update({hashSearch: {a: true, b: 'val'}})
scope.$location.updateHash('/hp', {a: true})
==> update({hashPath: '/hp', hashSearch: {a: true}})</pre>
</div>
</li>
</ul>
<h2>Properties</h2>
<ul class="properties"><li><h3>href</h3>
</li>
<li><h3>protocol</h3>
</li>
<li><h3>host</h3>
</li>
<li><h3>port</h3>
</li>
<li><h3>path</h3>
</li>
<li><h3>search</h3>
</li>
<li><h3>hash</h3>
</li>
<li><h3>hashPath</h3>
</li>
<li><h3>hashSearch</h3>
</li>
</ul>
<h2>Example</h2>
<doc:example><doc:source><a href="#">clear hash</a> |
<a href="#myPath?name=misko">test hash</a><br/>
<input type='text' name="$location.hash"/>
<pre>$location = {{$location}}</pre></doc:source>
</doc:example>