0

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

0

1 Answer 1

0

You can use conditional operator ?::

<div class="@(record closed?"":"bg-danger")"></div>

Here is an official doc about conditional operator ?:.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.