Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Rxjs 角度变化检测_Rxjs_Angular9 - Fatal编程技术网

Rxjs 角度变化检测

Rxjs 角度变化检测,rxjs,angular9,Rxjs,Angular9,我在组件的HTML中定义了以下内容: 重置密码 其中,[ladda]是一个自定义指令,当相应变量为true时,该指令在按钮上显示加载图标;在这种情况下,变量名为isLoading。通常我在点击服务器时会这样做,所以我会在点击服务器之前将isLoading设置为true,然后在返回响应时将其设置为false 当我尝试使用rxjs管道/最终确定模式时,这有点麻烦。如果运行以下操作,则不会检测到更改: this.passwordService.resetPassword(输入) .pipe(完成((

我在组件的HTML中定义了以下内容:

重置密码
其中,
[ladda]
是一个自定义指令,当相应变量为true时,该指令在按钮上显示加载图标;在这种情况下,变量名为
isLoading
。通常我在点击服务器时会这样做,所以我会在点击服务器之前将
isLoading
设置为true,然后在返回响应时将其设置为false

当我尝试使用rxjs管道/最终确定模式时,这有点麻烦。如果运行以下操作,则不会检测到更改:

this.passwordService.resetPassword(输入)
.pipe(完成(()=>this.isload=false))
.订阅(
()=>this.success=true,
err=>this.error=JSON.stringify(err)
);
我必须手动调用NgZone::run才能使其工作:

this.passwordService.resetPassword(输入)
.pipe(finalize(()=>this.ngZone.run(()=>this.isLoading=false)))
.订阅(
()=>this.success=true,
err=>this.error=JSON.stringify(err)
);
为什么,我做错了吗

更新-根据请求,以下是重置密码方法:

resetPassword(reset:IPasswordReset):可观察{
常量url=`${environment.ApiUrl}/Api/UserProfile/ResetPasswordFromToken`;
const options=新的HttpOptions();
options.headers=新的HttpHeaders();
options.headers=options.headers.append('Content-Type','application/x-www-form-urlencoded');
返回this.http.post(url,reset,null,options);
}

您尝试过完整的方法吗

this.passwordService.resetPassword(input)
    .subscribe(
        () => this.success = true,
        err => this.error = JSON.stringify(err),
        () => this.isLoading = false
    );

你能分享你的想法吗Directive@RafiHenig-我使用的是本例中的ladda指令:它在这里与使用setTimeout创建的简单observable一起工作。我不知道是什么原因导致您的可观察对象超出区域。您需要显示resetPassword方法的代码,该方法返回的可观察对象的完成情况将超出区域。它与ladda指令无关,当您在区域中设置isLoading时,它工作的事实意味着该指令按预期工作。@AdrianBrand-updated我必须遵循的编码范例使用rxjs管道/最终确定模式(这是为了工作),但我也尝试过,同样的事情也发生了,变化检测从未发生,所以ladda一直在旋转。