2015-10-29 98 views
0

我使用的角度,並有一個這樣的無線電輸入(在表格的,如果它事項):如何取消選擇所有無線電輸入?

<input type="radio" 
     name="inputName" 
     id="someId" 
     data-ng-value=true <!-- This select "true" for my ng-model when clicked--> 
     ng-model = "nameOfMyVarIn$scope" 
     ng-change = "thisRunsWhenSelectionIsmade(true)" 
     required></input> 

我要清除此輸入。清除綁定到ng-model的變量會清除變量,但不會清除複選框。我無法找到如何清除單選按鈕本身in the docsrandom articles - 它保持選中狀態。我從文檔中快速複製了示例,並添加了$scope.clearSelection - 目標是使此功能取消選擇所選輸入。在實際應用程序中,我在表單中有其他輸入,所以我不能只清除整個表單。

Plnkr

+0

呼叫'.reset段()'表單元素上。 –

+0

謝謝,基本上$ scope.nameOfForm.nameOfField.reset()? nameOfForm是表單的名稱屬性的值。 – VSO

回答

1

使用您Plnkr,我已經設置colornull和它的值清零。這是你想要的嗎?

$scope.clearSelection = function(){ 
    $scope.color = null; 
} 

這裏是updated Plnkr

+1

你回答了這個問題。它在我的項目中不起作用,但這是我的問題,直到我找出如何更好地在plnkr中複製問題。欣賞它無論如何。 – VSO

相關問題