มีวิธียกเลิกการสมัครรับการโทร http จากบริการเชิงมุมบน Destroy hook หรือไม่
ป.ล. ฉันทราบถึงตัวดำเนินการ 'take' ของ rxjs หรือการยกเลิกการสมัครบริการจากส่วนประกอบเอง
import { HttpClient } from "@angular/common/http";
import { Injectable, OnDestroy } from "@angular/core";
@Injectable()
export class SampleService implements OnDestroy {
constructor(private httpClient: HttpClient) {}
getSampleData() {
return this.httpClient.get("https://jsonplaceholder.typicode.com/todos/1");
}
ngOnDestroy(): void {
// automatically unsubscribe to service.
}
}