如果验证失败,则无法停止Metronic向导

时间:2019-12-14 13:27:36

标签: angular wizard metronic

验证失败时,我无法停止metronic向导。即使出现错误,它也会导航到下一步。 下面是我的代码。我尝试了下面的代码,但是form变量在wizard.on函数内部显示为未定义

    buildForm() {
        this.addLocationForm = this._fb.group({
            name: ['', Validators.required],
        });
    }
    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);
            }
        });

0 个答案:

没有答案
相关问题