使用参数并在新的浏览器选项卡中导航到aurelia路线

Ant*_*our 2 tabs routing aurelia

我可以将参数传递给路线并使用此代码导航到那里:

this.router.navigateToRoute('CaseList', { RefNo: this.selectedData.RefNo
},  { replace: true })
Run Code Online (Sandbox Code Playgroud)

参数正确传递到新页面.

但是,我想在新标签页中打开该页面.我试过了:

window.open(this.router.generate('CaseList', { RefNo:
this.selectedData.RefNo }),'_blank');
Run Code Online (Sandbox Code Playgroud)

这将打开一个新选项卡,并将参数值附加到URL,例如http:// localhost:49328/AppCaseMgmt/CaseList/20150000015,但如果我尝试在激活时读取参数的值,如下所示:

activate(params) {
    console.log('activate in case list');
    console.log(params.RefNo);
    ....
}   
Run Code Online (Sandbox Code Playgroud)

这是未定义的.

我正在使用路由器动态添加路由

this.router.addRoute({
        route: "/AppCaseMgmt/CaseList/:RefNo", name: "CaseList", moduleId: "app/case-management/case-list",
        title: "CaseMgmt:CaseManagement_SiteMapHeaderCaseManagement_title" });
    this.router.refreshNavigation();
Run Code Online (Sandbox Code Playgroud)

但据我所知,这不应该有所作为.(我尝试将路由添加到config.map,但没有成功).我开始认为这是不可能的.有没有人有任何想法?

谢谢,安东尼

Mar*_*agi 5

我无法重现此错误.不过,我想恢复奥里利亚你的信仰,所以这里是一个工作的演示根据你的使用情况.

我在重用相同的ViewModel之前遇到了类似的问题,但在这种情况下activated,第二次没有调用该事件.我已经通过replace根据Cheat Sheet更改VM的activationStrategy来解决这个问题

export class Product {
    determineActivationStrategy(){
        return activationStrategy.replace;
    }
}
Run Code Online (Sandbox Code Playgroud)

这可能会让您更接近解决方案.