如何打开 nebular "stepper" 取决于查询参数?

How to open nebular "stepper" depends on query params?

我正在尝试打开 nebular 'stepper' 步骤,这取决于查询参数。 例如:如果路线是/products/create?step=third 应该打开第三步

<nb-stepper [selected]="'second'">
  <nb-step [stepControl]="firstForm" [label]="first" #first>
   first
  </nb-step>
  <nb-step [label]="second" #second>
    second
  </nb-step>
  <nb-step [label]="third" #third>
    third
    <ng-template #third>Third step</ng-template>
  </nb-step>
</nb-stepper>

我试过使用 selected 属性,但没用

Get query params 在您的组件中并使用该参数设置选定的步骤,因此在您的组件中

selectedStep='second';

constructor(activatedRoute:ActivatedRoute){
this.activatedRoute.queryParams.subscribe((data)=>{
if(data['step']){
this.selectedStep =data['step']
}
})
}

并在 html

<nb-stepper [selected]="selectedStep">