<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<div ng-repeat='x in trail'>
<input type=checkbox ng-model='one1'>{{x}}</div>
<div ng-repeat='x in array'>
<p ng-hide='one1' >{{x}}</p>
</div>
</div>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.trail = ["Volvo","bike","access","rocket"];
$scope.array = ["Volvo","bike","access","rocket"];
});
</script>
</body>
</html>
当我运行它并单击任何复选框时,整个数组值应该隐藏,但不能隐藏。
答案 0 :(得分:0)
答案 1 :(得分:0)
如果你真的想要隐藏整个数组,你可以利用ng-change
指令传递模型
答案 2 :(得分:0)
实际上我发现你的例子有问题。如果创建ng-repeat并使用具有相同范围值的输入区域,则数组值不等于范围值。
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
$scope.trail = ["Volvo","bike","access","rocket"];
$scope.array = ["Volvo","bike","access","rocket"];
$scope.one = true;
}
<div ng-app="myApp" ng-controller="MyCtrl">
<input type="checkbox" ng-model="one">{{one}} {{x}}
<div ng-repeat='x in trail'>
</div>
<div ng-repeat='x in array'>
<label ng-show="one == true" >{{x}}</label>
</div>
</div>