Reputation: 19
I want to toggle class in tr when checkbox is checked. I am trying to learn angular pls guide me as a easiest way.
<tr class="unchecked_checkbox">
<td>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="two" id="flexCheckDefault" />
<label class="form-check-label" for="flexCheckDefault" />
</div>
</td>
</tr>
Upvotes: 1
Views: 684
Reputation: 767
You can use the ngClass, which allows you to have conditional classes over the element. So you just need to make the element look to the value that is going to be changed when the checkbox is marked.
Example:
<tr [ngClass]="{unchecked_checkbox: !two, checked_checkbox: two}">
<td>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="two" id="flexCheckDefault" />
<label class="form-check-label" for="flexCheckDefault">
</label>
</div>
</td>
</tr>
Upvotes: 1