我有一个模型在storeLocations对象中返回,其中包含isDefault值。如果isDefault返回true,则我希望将该组中的单选按钮设置为已选中。
不确定是否需要使用$each(data,function(index,value)迭代遍历每个返回的对象,或者是否有更容易使用angular结构进行此操作的方法。
对象:
storeLocations = [
{
... more values,
isDefault: true
}
]
标记语言:
<tr ng-repeat="location in merchant.storeLocations">
<td>{{location.name}}</td>
<td>{{location.address.address1}}</td>
<td>{{location.address.address2}}</td>
<td>{{location.address.city}}</td>
<td>{{location.address.stateProvince}}</td>
<td>{{location.address.postalCode}}</td>
<td>{{location.address.country}}</td>
<td>{{location.website}}</td>
<td>{{location.zone}}</td>
<td><input type="radio" ng-model="location.isDefault" value="{{location.isDefault}}" name="isDefault_group"></td>