症状: 绑定一个list radio button 老是只能绑定一行,纠结了很久 ,回家发现 原来是 name 用了同一个 ,坑啊,记录下 免得下次再犯。
之前的代码
<ul> <li ng-repeat="row in list"> <span> {{row.name}}</span> <label class="radio"> <input type="radio" name="abc" value="1" ng-model="row.type">ddddd</input> </label> <label class="radio"> <input type="radio" name="abc" value="2" ng-model="row.type">dfsfd</input></label> <label class="radio"> <input type="radio" name="abc" value="3" ng-model="row.type">sfd</input></label> Value:{{row.type}} </li> </ul>
改后的代码
<ul> <li ng-repeat="row in list"> <span> {{row.name}}</span> <label class="radio"> <input type="radio" name="abc{{row.name}}" value="1" ng-model="row.type">ddddd</input> </label> <label class="radio"> <input type="radio" name="abc{{row.name}}" value="2" ng-model="row.type">dfsfd</input></label> <label class="radio"> <input type="radio" name="abc{{row.name}}" value="3" ng-model="row.type">sfd</input></label> Value:{{row.type}} </li> </ul>