我正在尝试在弹出窗口关闭后执行代码。这是我的代码
onCompleteRegistration(accessCode: string) {
this.loader.start();
this.myService.completeSignup(this.token)
.subscribe((resp) => {
if (resp) {
...
} else {
...
}
this.loader.stop();
}, (error) => {
this.loader.stop();
this.errorService.openErrorPopup('Failed to complete registration. Please contact your HR representative.');
window.location.href = ...
});
}
我试图使window.location.href仅在关闭弹出窗口后才触发。有没有办法在此功能中做到这一点,或者我必须操纵弹出功能
答案 0 :(得分:0)
有什么阻止您拨打电话
window.location.href = ...
从订户的完成处理程序而不是错误处理程序开始?
答案 1 :(得分:0)
“ 订阅”具有3个分支:onNext,onError和onCompleted。 我想您应该添加第三个分支-onCompleted分支。 请参阅下面的3个分支示例:
@Order(1)
@Configuration
@EnableOAuth2Sso
public static class SecurityConfigurationAdapter extends WebSecurityConfigurerAdapter {
@Autowired
@Qualifier("defaultMatcher")
private RequestMatcher defaultMatcher;
@Override
protected void configure(HttpSecurity http) throws Exception {
http.requestMatcher(defaultMatcher)...
}
}
@Order(2)
@Configuration
public static class OtherConfigurationAdapter extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.requestMatcher(yourRequestMatcher())...
}
}
也许您应该在第3个分支/部分中添加重定向,这似乎在您的代码中丢失了。 https://aigeec.com/angularjs-2-do-something-when-my-observable-is-complete/