computed signal ngClass for every td in table in angular18

Discussão em 'Angular' iniciado por ss.x, Dezembro 27, 2024.

  1. ss.x

    ss.x Guest

    I need to calculate which class belongs to every td in my table according to specific logic for every td. I also need to detect changes and update the class if the data changes.

    What is the best practice to do it?

    Example:

    I have a cars signal data.

    cars = toSignal(this.dataService.cars);


    And I tried to write a computed like the following:

    carStatus: Signal<StatusEnum> = computed(() => this.calcStatus());


    This work fine to the first TD but I want to compute also the color (for example). Should I write more computed function to the color calculation?

    And what if I have 10 rows in the table? How to calculate the class for every td in every row?

    Continue reading...

Compartilhe esta Página