嵌套手风琴不守值Angularjs单选按钮 [英] Angularjs radio buttons in nested accordion do not keep values

查看:168
本文介绍了嵌套手风琴不守值Angularjs单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题。它的工作原理确定,如果我只有一个网站(一个手风琴),但是当我添加两个或两个以上的单选按钮不守的选择,网站会在飞行中添加

I got a problem. It works ok if I have ONLY one site (one accordion), but when I add two or more the radio buttons do not keep the selection, the sites are add on the fly

JavaScript的

JavaScript

$scope.proposal2      = {sites:[{}]};

$scope.addSite = function(type){      // function to add sites
    $scope.proposal2.sites.push({});
}

HTML

<div class="ibox-content">
   <div class="form-group">
      <!-- panel accordion1 -->
      <div class="panel-group" id="accordion1">
         <div class="panel panel-default" ng-repeat="site in proposal2.sites">
            <div class="panel-heading">
               <h5 class="panel-title">
                  <a data-toggle="collapse" data-parent="#accordion1" href="/proposal/new#collapse{{$index}}">Site {{$index}}</a>
               </h5>
            </div>
            <div id="collapse{{$index}}" class="panel-collapse collapse">
               <div class="panel-body">
                  <div class="accordion-inner">
                     <!-- panel accordion2 -->
                     <div class="panel-group" id="accordion-{{$index}}">
                        <div class="panel panel-default" ng-repeat="catf in categories | filter:{parent:1}">
                           <div class="panel-heading">
                              <h5 class="panel-title">
                                 <a data-toggle="collapse" data-parent="#accordion-{{$parent.$index}}" href="/proposal/new#collapse{{catf.id}}{{$parent.$index}}">{{catf.name}}</a>
                              </h5>
                           </div>
                           <div id="collapse{{catf.id}}{{$parent.$index}}" class="panel-collapse collapse">
                              <div class="panel-body">
                                 <label class="radio-inline" ng-repeat="cats in categories | filter:{parent:catf.id}">
                                 <input type="radio" name="type{{catf.id}}-{{$parent.$index}}" value="{{cats.id}}" ng-model="catf.cater" required="true" ng-change=""> {{cats.name}}
                                 </label>
                              </div>
                           </div>
                        </div>
                     </div>
                     <!-- panel accordion2 -->
                  </div>
               </div>
            </div>
         </div>
      </div>
      <!-- panel accordion1 -->
   </div>
</div>

当我选择NEC或松下它会从其他手风琴pviously选择的电话系统,如果我刚才在现场(一个手风琴)它只能如果我添加更多的站点(多手风琴)在$ P $选项这是行不通的。

When I select either Nec or panasonic it removes the option previously selected from the other accordions on "phone systems" it only works if I have just on site(one accordion) if I add more sites(more accordions) it doesn't work

在这个图像显示,当我选择NEC或其他网站松下previous选择删除(其他手风琴)

On this image shows that the previous selection is removed when I select Nec or panasonic on other site(other accordion)

到目前为止,我已经试过

So far I have tried

item.cater
$parent.item[catf.id][$parent.$index].cater
item[$parent.$index].cater

这些都不正在

在此先感谢!

推荐答案

我发现现在的解决方案是工作

I found the solution is working now

我有两个错误

解决方案

<input type="radio" name="type{{catf.id}}-{{$parent.$index}}-{{$parent.$parent.$index}}"  value="{{cats.id}}"  ng-model="site[$parent.$parent.$index].catf[catf.id].cats.id" required="true" ng-change="">

第一个错误的控件的名称应该是:

First mistake the name of the control should be :

name="type{{catf.id}}-{{$parent.$index}}-{{$parent.$parent.$index}}"

二NG-模型

ng-model="site[$parent.$parent.$index].catf[catf.id].cats.id"

结果

Sites [ { "0": { "catf": { "2": { "cats": { "id": "9" } }, "4": { "cats": { "id": "12" } }, "5": { "cats": { "id": "13" } } } } }, { "1": { "catf": { "2": { "cats": { "id": "9" } }, "4": { "cats": { "id": "11" } } } } }, { "2": { "catf": { "2": { "cats": { "id": "10" } }, "4": { "cats": { "id": "11" } } } } } ]

谢谢大家。

这篇关于嵌套手风琴不守值Angularjs单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆