【发布时间】:2020-08-28 11:58:43
【问题描述】:
我有一个显示为模态的组件(出现在我网站上的任何内容上方),该组件用作注册组件。它内部有一个注册表单,并将数据提交给服务。关于提交数据的一切工作,一切都成功地存储在我的数据库中。
但是当我想关闭我的模式时,问题就出现了。我尝试在订阅方法的第三个回调中执行关闭模式的方法:
this.userService.store(this.user).subscribe(
() => {
// Inform the user
this.success = 'Created successfully';
// Reset the form
this.registerForm.reset();
},
(err) => (this.error = err),
() => {
// Close the register form
document.getElementById('closeButton').click(); <- FUNCTION WHICH PERFORMS THE CLOSE GUI METHOD
}
);
我也尝试在订阅方法的第一个回调中调用该方法:
this.userService.store(this.user).subscribe(
() => {
// Inform the user
this.success = 'Created successfully';
// Reset the form
this.registerForm.reset();
// Close the register form
document.getElementById('closeButton').click(); <- FUNCTION WHICH PERFORMS THE CLOSE GUI METHOD
},
(err) => (this.error = err)
);
这些都不起作用,我可以在订阅函数之外调用此方法,但我只想在来自服务器的响应成功时关闭此组件。
【问题讨论】: