Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to use if/else condition in html table td

I want to ask how can I doing if/else condition in this tag?

 <td data-label="Status">{{$t('Status'+item.cStatus)}}</td>

What I want is

if(item.cStatus == NW){
color:red
}
else{
color:blue
}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can pass an object to :class (short for v-bind:class) to dynamically toggle classes:

<td :class="[item.cStatus == NW ? 'red' : 'blue']" data-label="Status">{{$t('Status'+item.cStatus)}}</td>

The above syntax means the presence of the red class will be determined by the truthiness of the data property item.cStatus == NW.

Then you can add your desired style to red or blue class


You can also do it by :style object

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading