Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何使用angularjs取消选中选中一个复选框的复选框_Html_Angularjs - Fatal编程技术网

Html 如何使用angularjs取消选中选中一个复选框的复选框

Html 如何使用angularjs取消选中选中一个复选框的复选框,html,angularjs,Html,Angularjs,我有三个复选框,如下所示: <input type="checkbox" ng-true-value="Orange" ng-model="selectMe1">Orange <input type="checkbox" ng-true-value="Pink" ng-model="selectMe2">Pink 橙色 粉红色 还有一个复选框用于清除所有复选框: <input type="checkbox" ng-true-value="none" ng-mod

我有三个复选框,如下所示:

<input type="checkbox" ng-true-value="Orange" ng-model="selectMe1">Orange
<input type="checkbox" ng-true-value="Pink" ng-model="selectMe2">Pink
橙色
粉红色
还有一个复选框用于清除所有复选框:

<input type="checkbox" ng-true-value="none" ng-model="clearMe">None

提前感谢您。

这些链接可能对您有帮助:


点击
ng中的
切换功能应该对您有所帮助。试试这个

<input type="checkbox" ng-true-value="0" ng-model="clearMe" ng-click="toggle()">None

这是一个可以帮助您的示例:

Html

 <div>
    <ul ng-controller="checkboxController">
        <li>Check All
            <input type="checkbox" ng-model="selectedAll" ng-click="checkAll()" />
        </li>
        <li ng-repeat="item in Items">
            <label>{{item.Name}}
                <input type="checkbox" ng-model="item.Selected" />
            </label>
        </li>
    </ul>
</div>

将此项添加到最后一个复选框
ng change=disableall()

在您的控制器上:

$scope.selectMe1 = false;//init
$scope.selectMe2 = false;//init
$scope.clearMe = false;//init

$scope.disableall() = function(){
    //let's say that you clear when the checkbox is true
     if($scope.clearMe){
           $scope.selectMe1 = false;
           $scope.selectMe2 = false;        
     }
}
希望有帮助,祝你好运。

简单的解决方案:

<input type="checkbox" ng-model="selectMe1">Orange
<input type="checkbox" ng-model="selectMe2">Pink

<input type="checkbox" ng-model="clearMe" ng-click="selectMe1=selectMe2=0;">None
橙色
粉红色
没有一个
试试这个,
全选

{{option.value}} {{options}} 角度.module(“app”,[]).controller(“ctrl”,函数($scope){ $scope.options=[ {value:'Option1',selected:true}, {value:'Option2',selected:false} ]; $scope.toggleAll=function(){ var-toggleStatus=false; forEach($scope.options,function(itm){itm.selected=toggleStatus;}); } });
当我尝试在ng上使用代码时,单击并将值设置为flase,但我的ng值和ng模型类似于定性。问题28.options.option1\u复选框,angular不接受此符号这正在工作,谢谢,我想问的另一件事,如何禁用未选中的复选框。橙色-粉红色,并添加$scope.disablee1=false和$scope.disablee2=false;
$scope.selectMe1 = false;//init
$scope.selectMe2 = false;//init
$scope.clearMe = false;//init

$scope.disableall() = function(){
    //let's say that you clear when the checkbox is true
     if($scope.clearMe){
           $scope.selectMe1 = false;
           $scope.selectMe2 = false;        
     }
}
<input type="checkbox" ng-model="selectMe1">Orange
<input type="checkbox" ng-model="selectMe2">Pink

<input type="checkbox" ng-model="clearMe" ng-click="selectMe1=selectMe2=0;">None
try this,
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js">    </script>
<div ng-app="app" ng-controller="ctrl">
<form id="selectionForm">
    <input type="checkbox" ng-click="toggleAll()" >Select all
    <br>
     <div ng-repeat = "option in options">
        <input type="checkbox" ng-model="option.selected" ng-change="optionToggled()">{{option.value}}
     </div>
</form>
  {{options}} 
</div>

<script>
angular.module("app", []).controller("ctrl", function($scope){

  $scope.options = [
    {value:'Option1', selected:true}, 
    {value:'Option2', selected:false}
  ];

  $scope.toggleAll = function() {
     var toggleStatus = false;
     angular.forEach($scope.options, function(itm){ itm.selected = toggleStatus; });

  }

});
</script>
<input type="checkbox" ng-true-value="none" ng-click="clearAll()" ng-model="clearMe">
 $scope.clearAll=function(){
     $scope.selectMe1=false;
     $scope.selectMe2=false;

 }