Add CSS in Pipe Angular2

Viewed 3049

Is it possible to add css in pipe? If not, can you suggest what is the workaround for this scenario? What I want is when backend returns negative values, it will be displayed as red without the negative sign, otherwise display normal (black text)

<td class="text-right">
    {{ value | myCustomPipe}}
</td>

My pipe file:

export class myCustomPipe implements PipeTransform {
  transform(value: string, ...args: any[]): string {
    if (+value < 0) {
      return (Math.abs(+value)).toFixed(2);  // possible to add css in here?
    } else if (+value === 0){
      return '-';
    } else {
      return (+value).toFixed(2);
    }
  }
0 Answers
Related