Есть ли способ отписаться от http-вызова службы angular onDestroy.
P.S. Мне известно об операторе «взять» 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.
}
}