我正在寻找实现URL的多租户路由机制:

myapp.com/tenant-1/dashboard,
myapp.com/tenant-2/dashboard.

最佳答案

您必须像这样声明路由,其中​​/:tenant_id将动态生成。

{
    path: 'tenant/:tenant_id',
    children: [
       { path: 'dashboard', component: DashboardComponent },
       { path: 'SomeOther', component: SomeOtherComponent }
    ]
}


您将使用以下代码阅读:tenant_id:

this.subscription = this.activatedRoute.queryParams.subscribe((params: Params) => {
       let tenant_id = params['tenant_id'];
       console.log(tenant_id);
});

关于angular - 如何在 Angular 实现 Multi-Tenancy 路由?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48438786/

10-15 21:38