Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

this.stepper.next() Causes the page to reload and again start from first Step #179

Open
ameysonawane opened this issue Jun 10, 2020 · 2 comments

Comments

@ameysonawane
Copy link

Hi , I have implemented basic Stepper module , but the issue is
when i click on next and it goes from Step 1 to Step 2 the page reloads itself and again it starts from step 1 .
Code 馃憥
component.ts

import { Component, OnInit } from '@angular/core';
import Stepper from 'bs-stepper';

@Component({
  selector: 'app-data-migration',
  templateUrl: './data-migration.component.html',
  styleUrls: ['./data-migration.component.css']
})
export class DataMigrationComponent implements OnInit {

  name = 'Angular';
  private stepper: Stepper;

  next() {
    this.stepper.next();
  }

  onSubmit() {
    return false;
  }

  constructor() { }

  ngOnInit() {
    this.stepper = new Stepper(document.querySelector('#stepper1'), {
      linear: false,
      animation: true
    })
  }

}

Component.html

<div class="container">
    <!-- <hello name="{{ name }}"></hello> -->
    <div id="stepper1" class="bs-stepper">
      <div class="bs-stepper-header">
        <div class="step" data-target="#test-l-1">
          <button class="step-trigger">
            <span class="bs-stepper-circle">1</span>
            <span class="bs-stepper-label">Email</span>
          </button>
        </div>
        <div class="line"></div>
        <div class="step" data-target="#test-l-2">
          <button class="step-trigger">
            <span class="bs-stepper-circle">2</span>
            <span class="bs-stepper-label">Password</span>
          </button>
        </div>
        <div class="line"></div>
        <div class="step" data-target="#test-l-3">
          <button class="step-trigger">
            <span class="bs-stepper-circle">3</span>
            <span class="bs-stepper-label">Validate</span>
          </button>
        </div>
      </div>
      <div class="bs-stepper-content">
        <form (ngSubmit)="onSubmit()">
          <div id="test-l-1" class="content">
            <div class="form-group">
              <label for="exampleInputEmail1">Email address</label>
              <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Enter email" />
            </div>
            <button (click)="next()" class="btn btn-primary">Next</button>
          </div>
          <div id="test-l-2" class="content">
            <div class="form-group">
              <label for="exampleInputPassword1">Password</label>
              <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password" />
            </div>
            <button (click)="next()" class="btn btn-primary">Next</button>
          </div>
          <div id="test-l-3" class="content text-center">
            <button type="submit" class="btn btn-primary mt-5">Submit</button>
          </div>
        </form>
      </div>
    </div>
  </div>
@manumohant
Copy link

give button type="button" and try

@rachidkarra
Copy link

rachidkarra commented Feb 4, 2021

Yes , it worked for me. Thanks @manumohant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants