docs(router): filter the event to subscribe (#37027)
The current code will not work as the `e` will be an event, If we try to access e.id and e.url it will throw an exception, the correct way is to use map or filter down to specific events PR Close #37027
This commit is contained in:
parent
5f64e52ed4
commit
77c0ef38be
|
@ -30,8 +30,8 @@ export type NavigationTrigger = 'imperative'|'popstate'|'hashchange';
|
|||
* class MyService {
|
||||
* constructor(public router: Router, logger: Logger) {
|
||||
* router.events.pipe(
|
||||
* filter(e => e instanceof RouterEvent)
|
||||
* ).subscribe(e => {
|
||||
* filter((e: Event): e is RouterEvent => e instanceof RouterEvent)
|
||||
* ).subscribe((e: RouterEvent) => {
|
||||
* logger.log(e.id, e.url);
|
||||
* });
|
||||
* }
|
||||
|
|
Loading…
Reference in New Issue