单选按钮检查所有按钮发出angularjs

时间:2015-03-21 08:53:39

标签: html radio-button name-attribute

我有这个plunk文件。在我的代码中,我想创建4个单选按钮,但我不知道为什么所有的单选按钮被检查时,它只是检查一个单选按钮。

http://plnkr.co/edit/IbtUGzuATbcSCmoDMH73

 <div class="row">
          <label class="col-sm-3">Choose Service Category:</label>
          <div class="col-sm-9">
              <div class="col-sm-3">
                <input type="radio" ng-model="">
                <label>Adhoc</label>
                <br/>
                <span>(One Time Service)</span>
              </div>
              <div class="col-sm-3">
                <input type="radio" ng-model="">
                <label>Semi-monthly</label>
                <br/>
                <span>(Every 2 Weeks)</span>
              </div>
              <div class="col-sm-3">
                <input type="radio" ng-model="">
                <label>Monthly</label>
                <br/>
                <span>(Once a Month)</span>
              </div>
              <div class="col-sm-3">
                <input type="radio" ng-model="">
                <label>Weekly</label>
                <br/>
                <span>(Once a Week)</span>
              </div>
          </div> 


    </div>

1 个答案:

答案 0 :(得分:2)

他们没有&#34;名称&#34;属性。要使单选按钮协同工作,它们需要具有相同的名称&#34; HTML属性:

<div class="row">
      <label class="col-sm-3">Choose Service Category:</label>
      <div class="col-sm-9">
          <div class="col-sm-3">
            <input type="radio" name="radio-group" ng-model="">
            <label>Adhoc</label>
            <br/>
            <span>(One Time Service)</span>
          </div>
          <div class="col-sm-3">
            <input type="radio" name="radio-group" ng-model="">
            <label>Semi-monthly</label>
            <br/>
            <span>(Every 2 Weeks)</span>
          </div>
          <div class="col-sm-3">
            <input type="radio" name="radio-group" ng-model="">
            <label>Monthly</label>
            <br/>
            <span>(Once a Month)</span>
          </div>
          <div class="col-sm-3">
            <input type="radio" name="radio-group" ng-model="">
            <label>Weekly</label>
            <br/>
            <span>(Once a Week)</span>
          </div>
      </div> 


</div>