Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
837 views
in Technique[技术] by (71.8m points)

angular - move in any step of nebular stepper

I am working with Nebular in angular 2, I am using the stepper with four steps, how can I move with the buttons of the steps to any desired step ? without having previously selected the steps ?, for example from step 1 to step 4 or from step 1 to step 3, but it does not allow me to perform these actions.

enter image description here

For this example I will use the code from the documentation. nbsteppercomponent

import { Component } from '@angular/core';

@Component({
  template: `
    <nb-card>
      <nb-card-body>
        <nb-stepper orientation="horizontal" disableStepNavigation>
          <nb-step [label]="labelOne">
            <ng-template #labelOne>First step</ng-template>
            <h4>Step content #1</h4>
            <p class="lorem">
              Lorizzle ipsum dolizzle stuff fizzle, consectetuer adipiscing break it down.
              Nullizzle sapien velizzle, my shizz pimpin', shizzle my nizzle crocodizzle shut the shizzle up,
              gravida vizzle, dang.
            </p>
            <button class="prev-button" nbButton disabled nbStepperNext>prev</button>
            <button class="next-button" nbButton nbStepperNext>next</button>
          </nb-step>
          <nb-step [label]="labelTwo">
            <ng-template #labelTwo>Second step</ng-template>
            <h4>Step content #2</h4>
            <p class="lorem">
              Lorizzle ipsum dolizzle stuff fizzle, consectetuer adipiscing break it down.
              Nullizzle sapien velizzle, my shizz pimpin', shizzle my nizzle crocodizzle shut the shizzle up,
              gravida vizzle, dang.
            </p>
            <button class="prev-button" nbButton nbStepperPrevious>prev</button>
            <button class="next-button" nbButton nbStepperNext>next</button>
          </nb-step>
          <nb-step label="Third step">
            <h4>Step content #3</h4>
            <p class="lorem">
              Lorizzle ipsum dolizzle stuff fizzle, consectetuer adipiscing break it down.
              Nullizzle sapien velizzle, my shizz pimpin', shizzle my nizzle crocodizzle shut the shizzle up,
              gravida vizzle, dang.
            </p>
            <button class="prev-button" nbButton nbStepperPrevious>prev</button>
            <button class="next-button" nbButton nbStepperNext>next</button>
          </nb-step>
          <nb-step [label]="labelFour">
            <ng-template #labelFour>Fourth step</ng-template>
            <h4>Step content #4</h4>
            <p class="lorem">
              Lorizzle ipsum dolizzle stuff fizzle, consectetuer adipiscing break it down.
              Nullizzle sapien velizzle, my shizz pimpin', shizzle my nizzle crocodizzle shut the shizzle up,
              gravida vizzle, dang.
            </p>
            <button class="prev-button" nbButton nbStepperPrevious>prev</button>
            <button class="next-button" nbButton disabled nbStepperNext>next</button>
          </nb-step>
        </nb-stepper>
      </nb-card-body>
    </nb-card>
  `,
  styleUrls: ['./stepper-disabled-step-nav.component.scss'],
})
export class StepperDisabledStepNavComponent {}
question from:https://stackoverflow.com/questions/65886774/move-in-any-step-of-nebular-stepper

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You need to disable the linear mode adding this code:

<nb-stepper [linear]=false orientation="horizontal" disableStepNavigation>

then you can add a function inside your button to navigate wherever your want between your steps


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...