B
B
bullyy2016-02-10 12:47:42
Angular
bullyy, 2016-02-10 12:47:42

How to organize work with radio-button true/false?

$scope.content = {
    values: [{
      value: "Option 1",
      checked: false
    }, {
      value: "Option 2",
      checked: true
    }, {
      value: "Option 3",
      checked: false
    }]
  }

<div radio-button-group class="container component simple-text">
  <div class="row">
    <div class="col-md-12">
      <label ng-repeat="c in content.values" class="radio-inline">
        <input type="radio" name="optradio" ng-model="c.checked"/>
        {{c.value}}
      </label>
    </div>
  </div>
</div>

I would like to make it so that when a certain component is selected, it becomes true, others false. I did it through ng-checked, can it be easier to implement?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rakro, 2016-02-10
@rakro

https://docs.angularjs.org/api/ng/input/input%5Bra...
ng-model - there should be one variable for all radios

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question