我正在寻找实现 Multi-Tenancy 路由机制,其中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/