[英]Why isn't my angular radio button marked as selected ( i have to click twice)
<li ng-repeat="flagVm in flagVms track by $id(flagVm)">
<label for="alternative{{$index}}" ng-click="alternativeClicked()">
<input ng-model="$parent.alternative" value="{{ flagVm.id }}" type="radio" name="alternative{{$index}}" />
<span class="num-times-flagged">(Flagged {{ flagVm.count }} {{ flagVm.count > 1 ? 'times' : 'time' }}) </span>
Inference Id:
<span class="highlighted-id">{{ flagVm.duplicateId }}</span>
</label>
</li>
and 和
$scope.alternativeClicked = function (id)
{
//once iterating will probably be the actual flag obj
$scope.alternativeFound = 'yes';
};
I think using ng-click
with radio is a bad practice. 我认为将
ng-click
与radio结合使用是一种不好的做法。
The better way is to use ng-change
or $watch
value change 更好的方法是使用
ng-change
或$watch
value更改
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.