I'm quite new to angular so perhaps the answer is right in front of my face, especially since I've seen very similar questions but none have worked for me. As the title suggests, I am trying to change ng-class
based on which of 3 radio buttons is selected within an ng-repeat
. Some things I've tried in example is ng-click
though this seems to behave with a boolean true / false
behavior, where I think I need more of a switch
-like behavior. I've also tried the solution here though this doesn't seem to work in a conditional case. Here is what I am working with:
<div class="col-md-4 col-sm-4 col-xs-12 projectType" ng-repeat="type in types">
<label>
<span class="typeIcon" ng-class="type.icon"></span>
<p>{{ type.name }}</p>
<input type="radio" name="type" ng-value="type" ng-model="$parent.selectedType" />
</label>
</div>
<div class="col-md-12 col-sm-12 col-xs-12" ng-hide="selectedType.id !== 1">
<input type="text" ng-hide="selectedType.id !== 1" ng-disabled="selectedType.id !== 1">
</div>
<div class="col-md-12 col-sm-12 col-xs-12" ng-hide="selectedType.id !== 2">
<input type="text" ng-hide="selectedType.id !== 2" ng-disabled="selectedType.id !== 2">
</div>
<div class="col-md-12 col-sm-12 col-xs-12" ng-hide="selectedType.id !== 3">
<input type="text" ng-hide="selectedType.id !== 3" ng-disabled="selectedType.id !== 3">
</div>
The controller simply applies features to each type, such as an id and name.
What I am specifically trying to do is change the background-color
of the parent label when the radio
is selected. I additionally added some divs below that also toggle based on which radio
is selected to show some existing logic that may be a barrier or asset for any possible solutions. I know this may be a very simple task in angular, so I appreciate your patience and help.