我正在尝试创建这样一个类似树的复选框:
- o Tree 2
- o Subtree 1
- o Subtree 2
其中,每个“o”都是一个复选框,函数包括:
我试过的是:
演示
函数Ctrl($scope) { $scope.billing_is_shipping =真;$scope.master =真;$scope.child =真;$scope.grandchlid =真;$scope.checked =函数(类型){ case (type) {case 'master':$scope.master = !$scope.master;if ($scope.master) { $scope.child = true;$scope.grandchild = true;} $scope.child = false;$scope.grandchild = false;} $scope.apply();打断;case 'child':$scope.child = !$scope.child;if ($scope.child) { $scope.grandchild = true;}if{ $scope.grandchild = false;} $scope.apply();break;大小写‘grandchild1 1’:$scope.grandchild1 = !$scope.grandchild1;if(!$scope.grandchild1欧元!$scope.grandchild2){ $scope.child = false;$scope.master = false;} console.log($scope.billing_is_shipping) }
}
我尝试过$scope.apply(),但没有,但我只能让第一次点击开始工作,然后一切都放弃了。
任何方法或帮助将不胜感激,并在此之前感谢。
发布于 2014-11-21 02:47:52
我刚刚就此编写了一个指令,您可以使用它拥有任意级别的复选框。基本上,它递归地检查上面描述的逻辑。查看存储库和现场演示。
https://stackoverflow.com/questions/25438792
复制相似问题