验证失败时,我无法停止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);
}
});