Reload current page in Aurelia

前端 未结 4 1703
醉酒成梦
醉酒成梦 2021-01-03 22:35

I have an Aurelia application where the user can select the company they\'re currently \"working on\". Every page in the app is dependent on the currently selected company,

4条回答
  •  失恋的感觉
    2021-01-03 23:37

    Better answer:

    this.router.navigateToRoute(
      this.router.currentInstruction.config.name,
      {
        ...this.router.currentInstruction.params,
        reload: Number(this.router.currentInstruction.queryParams.reload || 0) + 1,
      },
      { trigger: true },
    );
    

    The navigateToRoute() takes 3 parameters:

    1. Name of route: (get from current instruction)
    2. Route parameters: (get from current instruction and add an incremental reload to change the route; easiest way to make the router actually navigate)
    3. Options: The trigger: true option forces an activationStrategy: invokeLifecycle on this specific routing instruction without the need to set this option in the viewModel or routeConfig for normal routing.

提交回复
热议问题