Property 'filter' does not exist on type 'Observable'

后端 未结 7 1375
盖世英雄少女心
盖世英雄少女心 2021-01-31 13:38

Hi I am using Angular 2 final with router 3.0. I want to filter the events that are emitted from this.router.events

What I want to do :



        
7条回答
  •  借酒劲吻你
    2021-01-31 14:19

    Angular Update(5.x to 6.x) also comes with update of rxjs from 5.x to 6.x So simply add

    import { filter } from 'rxjs/operators';
    

    then

    this.router.events.pipe(
      filter((event:Event) => event instanceof NavigationEnd)
    ).subscribe(x => console.log(x))
    

    Hope That helps someone

提交回复
热议问题