$route
(service in module ng
)
Is used for deep-linking URLs to controllers and views (HTML partials).
It watches $location.url()
and tries to map the path to an existing route definition.
You can define routes through $routeProvider
's API.
The $route
service is typically used in conjunction with ngView
directive and the $routeParams
service.
Reference to the current route definition.
Array of all configured routes.
Broadcasted after a route change.
current – {Route} –
Current route information.
previous – {Route} –
Previous route information.
Broadcasted before a route change.
next – {Route} –
Future route information.
current – {Route} –
Current route information.
The reloadOnSearch
property has been set to false, and we are reusing the same
instance of the Controller.
This example shows how changing the URL hash causes the $route
to match a route against the
URL, and the ngView
pulls in the partial.
Note that this example is using inlined templates
to get it working on jsfiddle as well.