【发布时间】:2020-06-29 09:22:17
【问题描述】:
我有一个表单,它采用一个参数来构造客户并将其链接到产品。现在我们添加了另一个参数以包含在 URL 中,但是我似乎无法从 URL 中获取它。
我做错了什么?感谢您的帮助!
网址:http://localhost:4200/check/98712?Id=803
我可以设法从“98712”中获取第一个参数,但不是 Id。
在我的app.module下
RouterModule.forRoot([
{ path: 'check/:cust', component: CheckComponent},
我曾尝试在此处添加 ID,但它不起作用。
在我的 Check 组件中,我取出了客户和 Id,但 Id 仍然是空的。
this.customer = this.route.snapshot.paramMap.get('cust');
this.Ids = this.route.snapshot.paramMap.get('Id'); //Ids since it could be several, hence the add of Id in the URL
我在 app-routing 中的路线
const routes: Routes = [
{ path: '', redirectTo: 'ms', pathMatch: 'full' },
{ path: 'ms', component: CheckComponent },
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
如果您需要更多代码,请告诉我。
【问题讨论】:
-
我认为这可能对您有所帮助stackoverflow.com/questions/47455734/…
标签: angular typescript