Added a reset option, so you can reuse the wizard.#19
Added a reset option, so you can reuse the wizard.#19karellodewijk wants to merge 3 commits intomaiyaporn:masterfrom
Conversation
|
i update node_modules/angular2-wizard/src/wizard.component.ts with the code "reset() { Now wizard.component.ts`import { Component, Output, EventEmitter, ContentChildren, QueryList, AfterContentInit } from '@angular/core'; import { WizardStepComponent } from './wizard-step.component';@component({ <li class="nav-item" *ngFor="let step of steps" [ngClass]="{'active': step.isActive, 'enabled': !step.isDisabled, 'disabled': step.isDisabled, 'completed': isCompleted}"> <a (click)="goToStep(step)">{{step.title}} <div class="card-footer" [hidden]="isCompleted"> <button type="button" class="btn btn-secondary float-left" (click)="previous()" [hidden]="!hasPrevStep || !activeStep.showPrev">Previous <button type="button" class="btn btn-secondary float-right" (click)="next()" [disabled]="!activeStep.isValid" [hidden]="!hasNextStep || !activeStep.showNext">Next <button type="button" class="btn btn-secondary float-right" (click)="complete()" [disabled]="!activeStep.isValid" [hidden]="hasNextStep">Done private _steps: Array = []; @output() constructor() { } ngAfterContentInit() { get steps(): Array { get isCompleted(): boolean { get activeStep(): WizardStepComponent { set activeStep(step: WizardStepComponent) { public get activeStepIndex(): number { get hasNextStep(): boolean { get hasPrevStep(): boolean { public goToStep(step: WizardStepComponent): void { public next(): void { public previous(): void { public complete(): void { } } My component codeAddNewComponent ` @ViewChild('wizard') wizard: WizardComponent; onComplete(e){ //do work this.wizard.reset();}` and when i run it showing this error |
|
I can't tell for certain without seeing your code, but you probably forgot to tag your wizard as in <form-wizard #wizard>. Also don't forget the change in the complete function, it's important or the onComplete trigger will fire before _isCompleted is set and _isCompleted will be set right back to true after you reset. |
|
Not working |
|
Can i see your html, basically your html has a somewhere, you tag it with a name, like <form-wizard #wizard>. Then you bind the component in your ts like so: @ViewChild('wizard') And now wizard contains the wizard component and you can call functions on it. Something in that process is not working right because wizard is undefined, so is never bound to the wizard component. |
|
Ok now did you try to change <form-wizard> to
<form-wizard #wizard> ?
…On Wed, Oct 4, 2017 at 2:48 PM, Midhilaj ***@***.***> wrote:
my html
<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>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#19 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA3uD_ArEEt7lGqXlcSvtn2CJQi_e9lBks5so36PgaJpZM4NViAt>
.
|
|
Okay, great it works |
|
Thanks @karellodewijk |
|
|
|
I am looking forward to this feature, what happened then? Will it be merged, or it doesn't work? |
Nothing fancy, just a reset button, so you can do something like