Keep a count in scope
$scope.count = 0;
$scope.selectedIndex = {};
$scope.count = function (index){
$scope.selectedIndex[index] = 1;
updateCount();
}
$scope.uncount = function (index){
delete $scope.selectedIndex[index];
updateCount();
}
function updateCount(){
var element_count =0;
for (e in $scope.selectedIndex)
{
element_count++;
}
$scope.count = element_count;
}
and ng-click as below
<input type="radio" ng-click="count({{$index}})" name="item{{$index}}" ng-model="selectedVal" value="1" ng-selected="selectedVal==1">
<input type="radio" ng-click="uncount({{$index}})" name="item{{$index}}" ng-model="selectedVal" value="1" ng-selected="selectedVal==1">
display count here
<div>{{count}} of {{numRequired}}</div>
Or You can directly change count using ng-change
<input type="radio" ng-change={{count + 1}} name="item{{$index}}" ng-model="selectedVal" value="1" ng-selected="selectedVal==1">
<input type="radio" ng-change={{count -1}} name="item{{$index}}" ng-model="selectedVal" value="1" ng-selected="selectedVal==1">
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…