Navigating to an aurelia route with a parameter and in a new browser tab


I can pass a parameter to a route and navigate there using this code:

this.router.navigateToRoute('CaseList', { RefNo: this.selectedData.RefNo
},  { replace: true })

The parameter is passed correctly to the new page.

However, I would like to open the page in a new tab. I’ve tried:'CaseList', { RefNo:
this.selectedData.RefNo }),'_blank');

This opens a new tab and appends the parameter value to the URL e.g. http://localhost:49328/AppCaseMgmt/CaseList/20150000015, but if I try to read the value of the parameter on activation like this:

activate(params) {
    console.log('activate in case list');

it’s undefined.

I am adding the route dynamically to the router using

        route: "/AppCaseMgmt/CaseList/:RefNo", name: "CaseList", moduleId: "app/case-management/case-list",
        title: "CaseMgmt:CaseManagement_SiteMapHeaderCaseManagement_title" });

but that shouldn’t make a difference as far as I’m aware. (I’ve tried adding the route to the instead but without success). I’m beginning to think this isn’t possible. Has anyone any ideas?



I couldn’t reproduce this error.
However, I’d like to restore your faith in Aurelia, so here is a working demo with source according to your use case.

I ran into a similar issue before when reusing the same ViewModel, but in that case the activated event had not been called for the second time.
I’ve solved that by changing the VM’s activationStrategy to replace according to Cheat Sheet

export class Product {
        return activationStrategy.replace;

This might bring you closer to the solution.

Leave a Reply

Your email address will not be published. Required fields are marked *