Coder Social home page Coder Social logo

angular2-wizard's Introduction

angular2-wizard

npm version Build Status Code Climate Test Coverage

This is an Angular2 Form Wizard component. Just like any form wizard. You can define steps and control how each step works. You can enable/disable navigation button based on validity of the current step. Currently, the component only support basic functionality. More features will come later.

You can checkout the demo below and see how to use it in the next section.

Demo

https://maiyaporn.github.io/angular2-wizard-demo/

Dependencies

  • Angular2 (tested with 2.3.1)
  • Bootstrap 4

Installation

After installing the above dependencies, install angular2-wizard via:

$ npm install angular2-wizard --save

How to use the component

Once you have installed the library, you can import it in AppModule of your application:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';

// Import your library
import { FormWizardModule } from 'angular2-wizard';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    // Specify the library as an import
    FormWizardModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Once your library is imported, you can use form-wizard and wizard-step components in your Angular application:

<form-wizard>
  <wizard-step [title]="'Step1'" [isValid]="emailForm.form.valid" (onNext)="onStep1Next($event)">
    <h1>Step1</h1>
    <form #emailForm="ngForm">
      <div class="form-group">
        <label for="exampleInputEmail1">Email address</label>
        <input type="email" class="form-control" id="exampleInputEmail1" name="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email"
          [(ngModel)]="data.email" required>
        <small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
      </div>
    </form>
  </wizard-step>
  <wizard-step [title]="'Step2'" (onNext)="onStep2Next($event)">
    <h1>Step2</h1>
  </wizard-step>
  <wizard-step [title]="'Step3'" (onNext)="onStep3Next($event)">
    <h1>Step3</h1>
  </wizard-step>
  <wizard-step [title]="'Step4'" (onComplete)="onComplete($event)">
    <div [ngSwitch]="isCompleted">
      <div *ngSwitchDefault>
        <h1>Step4</h1>
      </div>
      <div *ngSwitchCase="true">
        <h4>Thank you! You have completed all the steps.</h4>
      </div>
    </div>
  </wizard-step>
</form-wizard>

Document

https://github.com/maiyaporn/angular2-wizard/wiki

Development

To generate all *.js, *.js.map and *.d.ts files:

$ npm run tsc

To lint all *.ts files:

$ npm run lint

Improvement

  • Click title to navigate
  • Hide/Show navigation button
  • Disable visited steps after navigate to previous
  • Dynamically add/remove step

License

MIT © Maiyaporn Phanich

angular2-wizard's People

Contributors

maiyaporn avatar daasalbion avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.