首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如果验证失败,如何停止Metronic向导

如果验证失败,如何停止Metronic向导
EN

Stack Overflow用户
提问于 2019-12-15 15:31:12
回答 2查看 1.6K关注 0票数 0

即使出错,它也会导航到下一步。下面是我的code.Please帮助

代码语言:javascript
运行
复制
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);
        }
    });
EN

回答 2

Stack Overflow用户

发布于 2020-04-28 16:53:57

还有另一种方法

代码语言:javascript
运行
复制
// Validation before going to next page
wizard.on("beforeNext", wizardObj => {
  if (wizardObj.currentStep === 1) {
    if (this.form.invalid) {
      this.form.markAllAsTouched();
      wizardObj.stop();
    }
  }
});
票数 2
EN

Stack Overflow用户

发布于 2020-01-31 18:49:30

现在可能太晚了,但这应该是可行的:

代码语言:javascript
运行
复制
function (wizardObj) {
    step = wizardObj.getStep();
    const form = this.addLocationForm as FormGroup;
    if(!form.valid) {
        wizardObj.goTo(step);
    }
});

检索当前步骤:

代码语言:javascript
运行
复制
step = wizardObj.getStep();

转到具体步骤:

代码语言:javascript
运行
复制
wizardObj.goTo(step);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59342006

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档