這裏的問題是,你不能插入一個角值到attr name
。如果我們從我們的HTML中刪除名稱attr,我們會得到預期的結果。 見下文。
<div ng-app="sample">
<div ng-controller="sampleController as sample">
Single ng-repeat:
<div ng-repeat="queue in sample.queues">{{queue.name}} status:
<input type="radio" name="queue-{{$index}}" ng-model="queue.condition" value="hooked" /> hooked
<input type="radio" name="queue-{{$index}}" ng-model="queue.condition" value="unhooked" /> unhooked
<input type="radio" name="queue-{{$index}}" ng-model="queue.condition" value="partial" /> partial
</div>
<br />
Nested ng-repeat:
<div ng-repeat="qm in sample.qms">
{{qm.name}} queues:
<div ng-repeat="queue in qm.queues">{{queue.name}} status:
<input type="radio" ng-model="queue.condition" value="hooked" /> hooked
<input type="radio" ng-model="queue.condition" value="unhooked" /> unhooked
<input type="radio" ng-model="queue.condition" value="partial" /> partial
</div>
</div>
</div>
</div>
如果我們要動態地包括名稱,看看成角的名字指令如:Dynamic form name attribute <input type="text" name="{{ variable-name }}" /> in Angularjs
感謝問這個問題:) –