# Tìm lỗi: Angular > Một đoạn mã. Tìm ra lỗi, hoặc chứng minh là không có lỗi nào. Thử thách hàng ngày: 2026-08-19 (UTC) · Mid-Level ```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) {} } ``` ## Phán quyết của bạn - Lỗ hổng bảo mật - Lỗi logic - Phong cách mã - Không có vấn đề Một lần thử mỗi ngày. Đáp án hiện ra ngay sau đó. --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/vi/thu-thach-hang-ngay/angular