即使出错,它也会导航到下一步。下面是我的code.Please帮助
ngAfterViewInit() {
// Initialize form wizard
const wizard = new KTWizard(this.el.nativeElement, {
startStep: 1
});
// Validation before going to next page
wizard.on('beforeNext', function (wizardObj) {
// validate the form and use below function to stop the wizard's step
const form = this.addLocationForm as FormGroup;
if(!form.valid) {
wizardObj.stop();
console.log(form.errors);
}
});
发布于 2020-04-28 08:53:57
还有另一种方法
// Validation before going to next page
wizard.on("beforeNext", wizardObj => {
if (wizardObj.currentStep === 1) {
if (this.form.invalid) {
this.form.markAllAsTouched();
wizardObj.stop();
}
}
});
发布于 2020-01-31 10:49:30
现在可能太晚了,但这应该是可行的:
function (wizardObj) {
step = wizardObj.getStep();
const form = this.addLocationForm as FormGroup;
if(!form.valid) {
wizardObj.goTo(step);
}
});
检索当前步骤:
step = wizardObj.getStep();
转到具体步骤:
wizardObj.goTo(step);
https://stackoverflow.com/questions/59342006
复制