Javascript 角度素数NG-如何在路由器链接中为素数NG步骤添加查询字符串
我已经使用angular和prime NG创建了步骤,我想在步骤链接中添加查询字符串 我正在创建以下步骤-Javascript 角度素数NG-如何在路由器链接中为素数NG步骤添加查询字符串,javascript,angular,primeng,Javascript,Angular,Primeng,我已经使用angular和prime NG创建了步骤,我想在步骤链接中添加查询字符串 我正在创建以下步骤- <p-steps [model]="steps" [readonly]="false" [(activeIndex)]="activeIndex"></p-steps> for (let i = 0; i < this.steps.length; i++) { this.steps.push( { label:
<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]);
}
}
);
}
for(设i=0;i{
this.activeIndex=i+1;
this.clickStep(this.steps[i]);
}
}
);
}
这里我想添加带有链接的查询字符串。请为同样的问题提出解决办法
priming 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);
}
}
})
按如下方式使用路由器链接可能会导致此问题
routerLink: ["step?a=1&b=2"]
我可以使用以下代码添加带有prime NG steps链接的查询字符串-
queryParams: { "name": this.plugins[i].name }
完整的代码如下所示-
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);
}
}
});