0

ng-model does not change my radio button, selecting another option print the value in the ng-model does not change my HTML

<div class="btn-group" data-toggle="buttons" role="group">
  <label class="btn btn-outline btn-primary ">
    <input type="radio" name="turno"  ng-model="vm.turno" value="matutino" />
    <i class="icon wb-check text-active" aria-hidden="true"></i>Matutino
  </label>
  <label class="btn btn-outline btn-primary active">
     <input type="radio" ng-model="vm.turno" value="vespertino" />
     <i class="icon wb-check text-active" aria-hidden="true"></i>Vespertino
  </label>
  <label class="btn btn-outline btn-primary">
    <input type="radio" ng-model="vm.turno" value="nocturno" />
    <i class="icon wb-check text-active" aria-hidden="true"></i>Nocturno
 </label>
</div>

<span>{{vm.turno}}</span>

4 Answers 4

1

You left out name on 2 of the radios. That is what groups them together

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

2 Comments

That is not the problem, it works fine if I remove the data-toggle = "buttons" of the div, known to be overheard.
then create a demo that replicates problem. Not really clear what it is from the description
1

have you set vm = this in your controller?
or maybe you have set the vm.turno to the other type
it works well in my code
plunker

Comments

1

vm.turno it is radio button whose default value is

boolean true or false.

These boolean value can not be printable in html.

You can try like this if you want to see the change

{{vm.turno ? "true" : "false"}}

Comments

1

Thank you very much for your answers, I was able to resolve the detail was ui.bootstrap use, instead of using a regular radio input, use a label with btn-radio, I remain as follows.

<div class="btn-group">
  <label class="btn btn-outline btn-primary" btn-radio="'matutino'" ng-model="vm.turno">
   <i class="icon wb-check text-active" aria-hidden="true"></i>Matutino
  </label>
  <label class="btn btn-outline btn-primary active" btn-radio="'vespertino'" ng-model="vm.turno">
   <i class="icon wb-check text-active" aria-hidden="true"></i>Vespertino
  </label>
  <label class="btn btn-outline btn-primary" btn-radio="'nocturno'" ng-model="vm.turno">
   <i class="icon wb-check text-active" aria-hidden="true"></i>Nocturno
  </label>
</div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.