Back in the good ole days of basic HTML and CSS, I was able to achieve the following:
input:checked+label {
background-color: #f00;
}
<div class="col-xs-6">
<input type="radio" id="template-1" name="template" value="template1" checked>
<label for="template-1">Example 1</label>
</div>
<div class="col-xs-6">
<input type="radio" id="template-2" name="template" value="template2">
<label for="template-2">Example 2</label>
</div>
However, when attempting to replicate the same snippet within an Angular form using ngModel
, the CSS doesn't take effect upon loading. It only applies after clicking one of the buttons.
Check out the Angular Plunkr example here
It seems like the radio button is not recognizing the checked
attribute? How can I ensure that my Angular radio button starts off checked and also triggers the CSS styling?