The Router
is responsible for mapping URLs to components.
You can see the state of the router by inspecting the read-only field router.navigating
.
This may be useful for showing a spinner, for instance.
Concepts
Routers and component instances have a 1:1 correspondence.
The router holds reference to a number of RouterOutlet. An outlet is a placeholder that the router dynamically fills in depending on the current URL.
When the router navigates from a URL, it must first recognize it and serialize it into an
Instruction
.
The router uses the RouteRegistry
to get an Instruction
.
- Annotations
Constructors
- Router(RouteRegistry registry, Router parent, hostComponent, [ Router root ])
Properties
- currentInstruction → Instruction
-
The current
Instruction
for the routerread / write - hashCode → int
-
Get a hash code for this object.
read-only, inherited - hostComponent → dynamic
-
read / write
-
read / write
-
read / write
- parent → Router
-
read / write
- registry → RouteRegistry
-
read / write
- root → Router
-
read / write
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
Operators
-
operator ==(
other) → bool -
The equality operator.
inherited
Methods
-
auxRouter(
hostComponent) → Router -
Constructs a child router. You probably don't need to use this unless you're writing a reusable component.
-
childRouter(
hostComponent) → Router -
Constructs a child router. You probably don't need to use this unless you're writing a reusable component.
-
commit(
Instruction instruction, [ bool _skipLocationChange = false, bool _replaceState = false ]) → Future -
Updates this router and all descendant routers according to the given instruction
-
config(
List<RouteDefinition> definitions) → Future -
Dynamically update the routing configuration and trigger a navigation.
-
deactivate(
Instruction instruction) → Future -
Removes the contents of this router's outlet and all descendant outlets
-
generate(
List linkParams) → Instruction -
Generate an
Instruction
based on the provided Route Link DSL. -
isRouteActive(
Instruction instruction) → bool -
Given an instruction, returns
true
if the instruction is currently active, otherwisefalse
. -
Navigate based on the provided Route Link DSL. It's preferred to navigate with this method over
navigateByUrl
. -
Navigate via the provided instruction. Returns a promise that resolves when navigation is complete.
-
Navigate to a URL. Returns a promise that resolves when navigation is complete. It's preferred to navigate with
navigate
instead of this method, since URLs are more brittle. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed.
inherited -
recognize(
String url) → Future<Instruction> -
Given a URL, returns an instruction representing the component graph
-
registerAuxOutlet(
RouterOutlet outlet) → Future -
Register an outlet to notified of auxiliary route changes.
-
registerPrimaryOutlet(
RouterOutlet outlet) → Future -
Register an outlet to be notified of primary route changes.
-
Navigates to either the last URL successfully navigated to, or the last URL requested if the router has yet to successfully navigate.
-
subscribe(
void onNext(value), [ void onError(value) ]) → Object -
Subscribe to URL updates from the router
-
toString(
) → String -
Returns a string representation of this object.
inherited -
unregisterPrimaryOutlet(
RouterOutlet outlet) → void -
Unregister an outlet (because it was destroyed, etc).