How to apply a conditional style at angular 8

Asked

Viewed 270 times

-1

Good morning

I would like to include a conditional formatting in my project’s css.

This style would change as the product status and status are: New service, In progress, Completed or cancelled.

<p class="finalizado">
    {{ appointment.status }}
</p>

This would be the tag that would change the color according to the information of the appointment.status.

The other classes will be:

.andamento {
   color: #120ecc !important;
}
.solicitado {
   color: #7717c0 !important;
}
.cancelado {
   color: #CC000C !important;
}
  • It was not clear your question, whether what you want to change is the class or the tag!

  • I want to change the class

  • But what are the other classes?

  • Include classes in the question

1 answer

2


You can use ng Class

<p [ngClass]="{
     'sua-classe': appointment.status==='teste',
     'sua-outra-classe': appointment.status==='banana'
}" >     
  • Thank you very much already solved my problem. But could you help me in a new question? There would be some way to pass a property into the css file. For example, the default color of a class is 'red' and pass blue through HTML and call this color passed by HTML and change.

  • There is no way

Browser other questions tagged

You are not signed in. Login or sign up in order to post.