# Trouve le bug : Angular > Un extrait de code. Trouve le bug, ou prouve qu'il n'y en a pas. Défi du jour: 2026-08-19 (UTC) · Confirmé ```typescript import { Injectable, Component } from '@angular/core'; import { BehaviorSubject } from 'rxjs'; @Injectable({ providedIn: 'root' }) export class CartService { private itemsSubject = new BehaviorSubject([]); items$ = this.itemsSubject.asObservable(); add(item: string) { this.itemsSubject.next([...this.itemsSubject.value, item]); } } @Component({ selector: 'app-cart-badge', template: `{{ (items$ | async)?.length }}`, providers: [CartService], }) export class CartBadgeComponent { items$ = this.cart.items$; constructor(private cart: CartService) {} } ``` ## Ton verdict - Faille de sécurité - Bug de logique - Style de code - Aucun problème Une tentative par jour. La réponse s'affiche juste après. --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/fr/defi-du-jour/angular