簡體   English   中英

如何在 ngx-admin 星雲步進器中以編程方式將一個步驟導航到另一個步驟?

[英]How to navigate one step to another steps programmatically in ngx-admin nebular stepper?

我正在使用ngx-admin模板。 我在星雲步進器中遇到了一些問題。 我在一個組件中使用了四個步驟。

我在組件文件中使用了 Nebular API 的方法:

@ViewChild("stepper") stepper: NbStepperComponent;

this.stepper.next();
this.stepper.previous();
this.stepper.reset();

next()導航到后續步驟。
previous()導航到前面的步驟。
reset()導航到第一步並重置所有表單數據。

如何從第 4 步導航到第 2 步?

使用這種方式,

在 HTML 文件中

 <nb-stepper #stepper [(selectedIndex)]="stepperIndex">

    <nb-step [stepControl]="serviceForm" label="Select Package">

    <button nbButton 
    (click)="backToSelectPackage()">ADD</button>

    </nb-step> 

 </nb-stepper>

在 Component.ts 文件中

stepperIndex: number = 0; // here 0 is initial index

backToSelectPackage() {
  this.stepperIndex = 0; // here 0 is navigate index
}

筆記:

如果使用[(selectedIndex)] ,我們不能使用 next(), Previous() 和 nbStepperNext, nbStepperPrevious。

this.stepper.goto(2);

它將導航到第二步...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM