Angular——路由跳转/传参/监听路由

 constructor(

    private router: Router,

private route: ActivatedRoute,

) {

}

if (event instanceof NavigationEnd) {
        if (this.route.snapshot.queryParams.id) {
          this.queryList.FileId = this.route.snapshot.queryParams.id;
          this.queryList.Offset = 0;
        } 
      }

 

 

this.router.navigate(['home/document/pulicDoc'], {queryParams: {id: res}});
this.isDocument =  this.router.events.subscribe((event: Event) => {
      if (event instanceof NavigationEnd) {
        this.fileActive = event.url.indexOf('pulicDoc') >= 0 || event.url.indexOf('proDoc') >= 0;
      }
    });
    this.unSpace = this.userSpaceService.spaceChange$.subscribe(res => {
      this.getUserInfO();
    });
  }
ngOnDestroy() {
    this.unSpace.unsubscribe();
    if(this.isDocument) {
      this.isDocument.unsubscribe();
    }
  }

 

你可能感兴趣的:(Angular)