/* * Copyright (c) 2016 VMware, Inc. All Rights Reserved. * This software is released under MIT license. * The full license information can be found in LICENSE in the root directory of this project. */ import {Component, ViewChild} from "@angular/core"; import {Wizard} from 'clarity-angular/wizard/wizard'; @Component({ selector: "clr-wizard-async-validation", templateUrl: "./wizard-async-validation.demo.html" }) export class WizardAsyncValidation { @ViewChild("wizard") wizard: Wizard; @ViewChild("myForm") formData: any; loadingFlag: boolean = false; errorFlag: boolean = false; onCommit(): void { let value: any = this.formData.value; this.loadingFlag = true; this.errorFlag = false; setTimeout(() => { if (value.answer === "42") { this.wizard.next(); } else { this.errorFlag = true; } this.loadingFlag = false; }, 1000); } code: string = ` import {Component, ViewChild} from "@angular/core"; import {Wizard} from "clarity-angular"; import {MyValidationService} from "service/my-validation"; @Component({ ... providers: [MyValidationService] }) export class WizardAsyncValidation { @ViewChild("wizard") wizard: Wizard; @ViewChild("myForm") formData: any; open: boolean = false; loadingFlag: boolean = false; errorFlag: boolean = false; onCommit(): void { let value: any = this.formData.value; this.loadingFlag = true; this.errorFlag = false; MyValidationService.validate(this.formData.value) .subscribe( data => { this.loadingFlag = false; // on passing validation, programmatically call next to move to next step this.wizard.next(); }, error => { this.loadingFlag = false; this.errorFlag = true; } ); } } `; html: string = `
Wizard Title
Async validation Wizard complete
Loading...
This wiki article might help you answer the question.
Your answer is incorrect.
Congratulations! Now you know the answer to life, the universe and everything!
`; }