[英]Angular Prime NG - How to add a query string in the router link for the Prime NG steps
I have created steps using angular and prime NG , I would like to add query string within the link of the steps.我已经使用 angular 和 prime NG 创建了步骤,我想在步骤的链接中添加查询字符串。
I am creating the steps as below -我正在创建如下步骤 -
<p-steps [model]="steps" [readonly]="false" [(activeIndex)]="activeIndex"></p-steps>
for (let i = 0; i < this.steps.length; i++) {
this.steps.push(
{
label: this.steps[i].name,
routerLink: ["step"],
command: (event: any) => {
this.activeIndex = i + 1;
this.clickStep(this.stepss[i]);
}
}
);
}
Here I would like to add query string with the link.在这里,我想添加带有链接的查询字符串。 Please suggest for any way out for the same?
请建议任何出路?
PrimeNG reference - https://primefaces.org/primeng/#/steps PrimeNG 参考 - https://primefaces.org/primeng/#/steps
Since Angular's change detection mechanism looks for a reference change, I would recommend using the map function since it returns a new array reference.由于 Angular 的更改检测机制会查找引用更改,因此我建议使用 map 函数,因为它返回一个新的数组引用。
this.steps = this.steps.map(step => {
return {
label: step.name,
routerLink: ["step?a=1&b=2"],
command: (event: any) => {
this.activeIndex = i + 1;
this.clickStep(step);
}
}
})
Using the router link as the following might to the trick使用路由器链接,如下所示可能是诀窍
routerLink: ["step?a=1&b=2"]
I am able to add the query string with prime NG steps link using the below code -我可以使用以下代码添加带有主要 NG 步骤链接的查询字符串 -
queryParams: { "name": this.plugins[i].name }
complete code would be like below-完整的代码如下-
this.steps = this.steps.map(step => {
return {
label: step.name,
routerLink: ["step?a=1&b=2"],
queryParams: { "name": this.plugins[i].name }
command: (event: any) => {
this.activeIndex = i + 1;
this.clickStep(step);
}
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.