trigger change detection for primitive attributs

Discussão em 'Angular' iniciado por Nesrine GHRIBI, Janeiro 10, 2025.

  1. It's the first time that I'm going to use change detection onPush in my project. I know that when we use this strategy, Angular will detect changes to input properties by comparing their object references, not their contents. If I add for example this code in a component using onpush, angular is not detecting the change, how can we resolve the problem ?

    this.boxService.selectedBox$.subscribe((box: Box | null) => {
    if (box && box.id && box.id === this.index ) {
    this.selected = true;
    } else {
    this.selected = false;
    }
    });


    thank you.

    Continue reading...

Compartilhe esta Página