2016-09-24 58 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}}" 

使用單引號。