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
92590693e6
commit
3813f54bec
@ -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…
x
Reference in New Issue
Block a user