如果选择任何选项,则按功能禁用AngularJS单选按钮

时间:2014-04-03 06:40:41

标签: angularjs radio-button

AngularJS还是新手,有人可以解释为什么我无法通过功能禁用单选按钮吗?

<td class="column" ng-repeat="item in row">
  <input type="radio" name="countries" value="{{item.right}}" id="{{item.name}}" ng-model="answer" ng-disabled="picked(currentIndex)" ng-change="newValue({{item.right}})">
  <label for="{{item.name}}">{{item.name}}</label>
</td>

控制器:

@IndexCtrl = ($scope) ->

  $scope.currentIndex = 0
  $scope.score = 0
  $scope.answered = []

  $scope.picked = (currentIndex) ->
    if $scope.answered.indexOf(currentIndex) is not -1
      return true 
    else
      return false

  $scope.newValue = (value) ->
    $scope.answered.push($scope.currentIndex) if $scope.answered.indexOf($scope.currentIndex) is -1
    ++$scope.score if value
    return

1 个答案:

答案 0 :(得分:0)

答案在于咖啡脚本:

is not vs isnt (=== ! vs !==) 

: - )