我正在尝试使用带有ng-repeat的单选按钮,但是在构建重复形式时,表单未绑定正确的方式,会错误所有单选-_-,我在做什么错呢?就像我单击单选按钮时一样,更改全部或全部不更改。我正在使用angular js 1并实现。

阿奎(Aqui:Parte da estrututa do objeto)

$scope.paineis = [
  {
    id:0,
    listaCotacoes:[
     {id:0, situacao:0},
     {id:1, situacao:4}
    ]
  },
  {
    id:1,
    listaCotacoes:[
     {id:6, situacao:0},
     {id:9, situacao:4}
    ]
  }
];

<tbody>
   <tr ng-repeat="cotacoes in painel.listaCotacoes | orderBy: 'situacao'">
      <td><a data-target="verCotacao" class="btn-floating teal modal-trigger"><i class="material-icons">description</i></a></td>
      <td ng-if="cotacoes.situacao == 0"><i class="material-icons light-blue-text text-accent-4">lock_open</i></td>
      <td ng-if="cotacoes.situacao == 2"><i class="material-icons gray-text">block</i></td>
       <td ng-if="cotacoes.situacao == 3"><i class="material-icons green-text">thumb_up</i></td>
       <td ng-if="cotacoes.situacao == 4"><i class="material-icons red-text">thumb_down</i></td>
       <td>21/02/2014</td>
       <td>
          <form action="">
              <div class="row">
                 <div class="col s3">
                    <p>
                       <input name="{{cotacoes.id}}" type="radio" id="aberta" ng-checked="cotacoes.situacao == 0"  value="0" ng-model="cotacoes.situacao"/>
                       <label for="aberta{{cotacoes.id}}">Abrir</label>
                   </p>
                 </div>
                 <div class="col s3">
                    <p>
                       <input name="{{cotacoes.id}}" type="radio" id="Finalizado" ng-checked="cotacoes.situacao == 2" value="2" ng-model="cotacoes.situacao"/>
                       <label for="Finalizado{{cotacoes.id}}">Finalizado</label>
                    </p>
                  </div>
                  <div class="col s3">
                     <p>
                        <input name="{{cotacoes.id}}" type="radio" id="Aprovar" ng-checked="cotacoes.situacao == 3" value="3" ng-model="cotacoes.situacao"/>
                        <label for="Aprovar{{cotacoes.id}}">Aprovar</label>
                     </p>
                   </div>
                   <div class="col s3">
                       <p>
                          <input name="{{cotacoes.id}}" type="radio" id="Reprovada" ng-checked="cotacoes.situacao == 4" value="4" ng-model="cotacoes.situacao"/>
                          <label for="Reprovada">Reprovar</label>
                       </p>
                     </div>
                  </div>
               </form>
             </td>
           </tr>
       </tbody>

最佳答案

如果您的单选按钮是一个组,即您必须从组中选择一个。名称"name="{{cotacoes.id}}""应该在所有这些名称上都匹配。因此,不是让它们在所有应该起作用的所有元素上都由name="{{cotacoes.id}}"更改为name="radio-group"

<li>
    <input type="radio" name="radio" id="radio2" ng-model="selectedItem.style_id" value="2">
    <label for="radio2"><img src="/angular/images/Theme-Light-2.png" alt="course_theme_2"></label>
</li>

<li>
     <input type="radio" name="radio" id="radio3" ng-model="selectedItem.style_id" value="3">
     <label for="radio3"><img src="/angular/images/Theme-Light-3.png" alt="course_theme_3"></label>
 </li>

 <li>
     <input type="radio" name="radio" id="radio4" ng-model="selectedItem.style_id" value="4">
     <label for="radio4"><img src="/angular/images/Theme-Light-4.png" alt="course_theme_4"></label>
 </li>

 <li>
     <input type="radio" name="radio" id="radio5" ng-model="selectedItem.style_id" value="5">
     <label for="radio5"><img src="/angular/images/Theme-Light-5.png" alt="course_theme_5"></label>
 </li>


name="" attribute groups radio button s

关于javascript - 用单选按钮重复执行错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45922239/

10-13 01:37