Senior
18 Kasım 2026

Hatayı bul: Angular

Tek bir kod parçası. Hatayı bul ya da hata olmadığını kanıtla.

typescript
1import { Directive, inject, DestroyRef } from '@angular/core';
2import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
3import { Observable } from 'rxjs';
4
5@Directive()
6export abstract class BaseListComponent<T> {
7  protected readonly destroyRef = inject(DestroyRef);
8
9  protected abstract load(): Observable<T[]>;
10
11  protected items: T[] = [];
12
13  protected refresh() {
14    this.load()
15      .pipe(takeUntilDestroyed(this.destroyRef))
16      .subscribe((data) => (this.items = data));
17  }
18}
19

Soruna yol açan satırlara tıkla.

Kararın

Günde bir deneme. Cevap hemen ardından görünür.

Serini koru

Serini korumak ve ilerlemeni takip etmek için hesap oluştur.

Hesap oluştur