Router class

The Angular router, which is represented as a stream of state changes.

In order to be notified when navigation is occurring listen to the stream:

class MyComponent implements OnInit {
  final Router _router;

  MyComponent(this._router);

  @override
  void ngOnInit() {
    _router.onRouteActivated.listen((newState) {
      print('Navigating from ${_router.current} to $newState');
    });
  }
}

Constructors

Router()

Properties

current RouterState
Current state of the router. [...]
read-only
onNavigationStart → Stream<String>
Emits the requested path when navigation starts. [...]
read-only
onRouteActivated → Stream<RouterState>
Emits the next router state after a new route is activated. [...]
read-only
stream → Stream<RouterState>
@Deprecated("Renamed to 'onRouteActivated'"), read-only
hashCode → int
The hash code for this object. [...]
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited

Methods

Attempts to navigate to a route that matches path. [...]
Attempts to navigate to a route that matches url. [...]
registerRootOutlet(RouterOutlet routerOutlet) → void
Registers the root routerOutlet and navigates to the current route. [...]
unregisterRootOutlet(RouterOutlet routerOutlet) → void
Unregisters the root routerOutlet. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() → String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) → bool
The equality operator. [...]
inherited