[英]How to unsubscribe from observable in Angular after http request and stop updating?
当我这样做时:
comments: Comment[] | undefined;
loadComments(){
this.http.get<Comment[]>(`${this.apiServerUrl}`, options).subscribe(
(response: Comment[]) => this.comments = response
);
}
如何取消订阅,并在 html 文件 static 中制作我的 output? 问题是,在我的项目中,我有很多订阅,当我启动我的应用程序时,它会吃掉我的内存。
实际上,您不必取消订阅 http observables。 一旦响应到达,它就完成了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.