How to router.navigate to same route in Angular 4 and catch the same event?

前端 未结 4 485
情深已故
情深已故 2021-01-02 08:35

Okay, I have two use cases for my question here:

  1. I\'m working on an application which has a /en/register route. It all works good when I\'m at t

4条回答
  •  一生所求
    2021-01-02 09:07

    For case 1,

    Why do you navigate to a new route just to open a modal. Just do it being at the same route with a function call. If you want to move to a new route then you can again call this.router.navigate("/") in modal close event.

    For case 2, Hope this will work.

    currentSearchQuery: string;
    
    ngOnInit() {
      this.route.paramMap
        .switchMap((params: ParamMap) => {
            this.currentSearchQuery = params.get('searchQuery');
            updateMarkers();
          });
    
    }
    

提交回复
热议问题