我试图在角度打字稿应用程序的按钮单击上制作如下所示的URL模式:
http://localhost:4200/SamplePage/scheduler?UsecaseId=3
用例。用例ID是一个数字值。
<td>
<button class="btn, btn-prmary btm-sm" type="button" (click)="redirectToChildPage('/SamplePage/scheduler?UsecaseId=usecase.UsecaseID')">
<i class="fa fa-calender"></i></button> Schedule
</td>
但是,我正在得到这个URL模式(实际)
http://localhost:4200/SamplePage/scheduler%3FUsecaseId%3Dusecase.UsecaseId
redirectToChildPage
redirectToChildPage(url) {
this.router.navigate([url]);
}
答案 0 :(得分:3)
redirectToChildPage(yourvalue) {
this.router.navigate(['url'], { queryParams: { query: yourvalue } });
}
您需要在函数中添加查询参数才能正常工作!
有关更多详细信息,您可以检查here!
解决方案
<td> <button class="btn btn-primary btn-sm" type="button" (click)="redirectToChildPage('/his/scheduler',usecase.UsecaseId)"> <i class="fa fa-calendar"></i></button> Schedule </td>
this.router.navigate([url], { queryParams: { UsecaseId: usercaseID } });
答案 1 :(得分:0)