2016-09-24 59 views
0

在我的代码中,通过循环,将创建两组单选按钮。 例如,动态更改单选按钮的名称

RadioButton1: a.Yes b.no 

RadioButton2: a.Yes b.no 

的问题是,我无法改变单选按钮dynamically.So的名字,当我在一个单选按钮检查组,另一组的元素被选中。

我的代码是 -

<div ng-repeat="t in getTimes(2) track by $index"> 
    <div> 
     <div> 
      <div ng-repeat="radioButton in 
            selection.head.avarageOrBestCount">s 
       <input type="radio" name=" 
            {{"avarageOrBestCount"+$parent.$index}}" 
        value="{{radioButton}}" ng-model="ss"> {{radioButton}}<br> 
      </div> 
     </div> 
     </div> 
    </div> 

我需要工作名称= “{{” avarageOrBestCount “+ $父。$指数}}”。我如何动态更改单选按钮的名称?

+0

尝试应用父命令/范围中的名称索引以及 –

+0

$ parent。$ index ... yah ..我尝试过了....但它不工作 –

+1

尝试此变种: name =“ avarageOrBestCount {{$ parent。$ index}}“ – Natiq

回答

0

您正在破坏属性字符串。双引号 “'” 或反之亦然内改变了...

name="{{"avarageOrBestCount"+$parent.$index}}" 

要这个......

name="{{'avarageOrBestCount'+$parent.$index}}" 

使用单引号。