How to apply CSS class only on selected item or clear CSS class applied on ion-radio

Asked

Viewed 92 times

0

I’m new to angular/Ionic development and I’m developing an application that needs to select an item from a radio and apply a CSS class only to the selected item.

The way it is implemented I am able to apply the classes to the items but it does not automatically clean the item that is no longer selected.

<form id="gerarSimulado-form25" class="list">
      <div class="spacer" style="width: 300px; height: 18px;"></div>

      <ion-item class="simulado_enunciado_item">
        <h3 class ="simulado_enunciado_font">{{simulado.questao}}</h3>
      </ion-item>

      <ion-radio  ng-class="{'item_selecionado':selecionado}" ng-repeat="alternativa in simulado.alternativas" id="gerarSimulado-radio5"
                 name="simulado_num_questoes" ng-click="setSiuladoResposta(simulado._id,alternativa);selecionado = !selecionado;">

        {{alternativa}}
      </ion-radio>
</form>

Any idea how to solve?

  • You can put a working model of your code so we can help you in the best way possible?

  • I ended up complicating a little more than I should trying to change the appearance by controllers, a colleague managed to solve the problem by setting the class directly in the CSS file, anyway thanks for the attention.

  • It would be interesting for you to answer the question with the final result of what you arrived at, so people with similar doubt can find the solution without asking a new question

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.