forked from angular/code.angularjs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathng.$routeProvider.html
82 lines (74 loc) · 4.58 KB
/
ng.$routeProvider.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
70
71
72
73
74
75
76
77
78
79
80
81
82
<h1><code ng:non-bindable="">$routeProvider</code>
<span class="hint">(service in module <code ng:non-bindable="">ng</code>
)</span>
</h1>
<div><h2 id="Description">Description</h2>
<div class="description"><p>Used for configuring routes. See <a href="api/ng.$route"><code>$route</code></a> for an example.</p></div>
<div class="member method"><h2 id="Methods">Methods</h2>
<ul class="methods"><li><h3 id="otherwise">otherwise(params)</h3>
<div class="otherwise"><p>Sets route definition that will be used on route change when no other route definition
is matched.</p><h4 id="Parameters">Parameters</h4>
<ul class="parameters"><li><code ng:non-bindable="">params – {Object} – </code>
<p>Mapping information to be assigned to <code>$route.current</code>.</p></li>
</ul>
<h4 id="Returns">Returns</h4>
<div class="returns"><code ng:non-bindable="">{Object}</code>
– <p>self</p></div>
</div>
</li>
<li><h3 id="when">when(path, route)</h3>
<div class="when"><p>Adds a new route definition to the <code>$route</code> service.</p><h4 id="Parameters">Parameters</h4>
<ul class="parameters"><li><code ng:non-bindable="">path – {string} – </code>
<p>Route path (matched against <code>$location.path</code>). If <code>$location.path</code>
contains redundant trailing slash or is missing one, the route will still match and the
<code>$location.path</code> will be updated to add or drop the trailing slash to exactly match the
route definition.</p>
<p><code>path</code> can contain named groups starting with a colon (<code>:name</code>). All characters up to the
next slash are matched and stored in <code>$routeParams</code> under the given <code>name</code> when the route
matches.</p></li>
<li><code ng:non-bindable="">route – {Object} – </code>
<p>Mapping information to be assigned to <code>$route.current</code> on route
match.</p>
<p>Object properties:</p>
<ul>
<li><code>controller</code> – <code>{(string|function()=}</code> – Controller fn that should be associated with newly
created scope or the name of a <a href="api/angular.Module#controller"><code>registered controller</code></a>
if passed as a string.</li>
<li><code>template</code> – <code>{string=}</code> – html template as a string that should be used by
<a href="api/ng.directive:ngView"><code>ngView</code></a> or
<a href="api/ng.directive:ngInclude"><code>ngInclude</code></a> directives.
this property takes precedence over <code>templateUrl</code>.</li>
<li><code>templateUrl</code> – <code>{string=}</code> – path to an html template that should be used by
<a href="api/ng.directive:ngView"><code>ngView</code></a>.</li>
<li><p><code>resolve</code> - <code>{Object.<string, function>=}</code> - An optional map of dependencies which should
be injected into the controller. If any of these dependencies are promises, they will be
resolved and converted to a value before the controller is instantiated and the
<code>$routeChangeSuccess</code> event is fired. The map object is:</p>
<ul><li><code>key</code> – <code>{string}</code>: a name of a dependency to be injected into the controller.</li>
<li><code>factory</code> - <code>{string|function}</code>: If <code>string</code> then it is an alias for a service.
Otherwise if function, then it is <a href="api/AUTO.$injector#invoke"><code>injected</code></a>
and the return value is treated as the dependency. If the result is a promise, it is resolved
before its value is injected into the controller.</li></ul></li>
<li><p><code>redirectTo</code> – {(string|function())=} – value to update
<a href="api/ng.$location"><code>$location</code></a> path with and trigger route redirection.</p>
<p>If <code>redirectTo</code> is a function, it will be called with the following parameters:</p>
<ul><li><code>{Object.<string>}</code> - route parameters extracted from the current
<code>$location.path()</code> by applying the current route templateUrl.</li>
<li><code>{string}</code> - current <code>$location.path()</code></li>
<li><code>{Object}</code> - current <code>$location.search()</code></li></ul>
<p>The custom <code>redirectTo</code> function is expected to return a string which will be used
to update <code>$location.path()</code> and <code>$location.search()</code>.</p></li>
<li><p><code>[reloadOnSearch=true]</code> - {boolean=} - reload route when only $location.search()
changes.</p>
<p>If the option is set to <code>false</code> and url in the browser changes, then
<code>$routeUpdate</code> event is broadcasted on the root scope.</p></li>
</ul></li>
</ul>
<h4 id="Returns">Returns</h4>
<div class="returns"><code ng:non-bindable="">{Object}</code>
– <p>self</p></div>
</div>
</li>
</ul>
</div>
</div>