hey everyone i have a question.
in my view i have a table that i show records in. if the record is closed the design of the table changes. right now my im doing this by @if(record closed) show <div></div> else show <div class="bg-danger"><div>
the content of the two divs are identical but the second one has bg-danger
there must be a way to get around this repeating content where i dont have to copy and paste the entire div
for each scenario.
How should i achieve that? is there a better way of setting up the view
You can use conditional operator ?:
:
<div class="@(record closed?"":"bg-danger")"></div>
Here is an official doc about conditional operator ?:
.