Angular用法中的清单模型

时间:2017-10-29 16:40:50

标签: javascript angularjs html5 checklist-model

我有部门作为标题,员工作为副标题。我想要做的是当用户检查标题或部门时,应检查所有员工或字幕。我在html和ng-repeat中使用fieldset和table。它看起来像这个问题,但主要区别在于从数据库Angular checklist-model checkboxes with reverse action获取数据 我找不到我想念的东西。任何想法任何帮助。谢谢 。

HTML

<fieldset id="field3">
            <table>
                <tr ng-repeat="emp in empdepts | groupBy:'dep_LDesc'">
                    <td>
                        <label ng-click="showContent = !showContent"></label>
                        <details ng-open="showContent">
                            <summary> <input type="checkbox" class="test" ng-model="check_all_domains" ng-click="toggle_select_all()" /> {{emp[0].dep_LDesc}}</summary>

                            <div ng-repeat="semployee in emp" class="test">

                                <input type="checkbox" checklist-model="objects_selected" checklist-value="semployee">

                                {{semployee.Sname}}<div style="display:none;">{{semployee.staffkey}}{{semployee.depkey}}</div>

                              </div>
                        </details>
                    </td>
                </tr>
            </table>
        </fieldset>

控制器

/// <reference path="Scripts/angular.js" />

/// ///

Assign.controller("AssignController", function ($scope, Assignments) {

Loaddepts();
function Loaddepts()
{
    Assignments.getdepts().then (function(response){

        $scope.depts = (response.data);
        console.log($scope.depts);
    })

}

//$scope.employees = [];
//$scope.checked = { employees: ['semployee'] }
//$scope.checkAll = function () {
//    $scope.checked.employees = angular.copy($scope.employees);
//};
//$scope.uncheckAll = function () {
//    $scope.checked.employees = [];
//};


//$scope.emp = $scope.empdepts;
$scope.objects_selected = [];
$scope.check_all_domains = false;
$scope.toggle_select_all = function () {
    $scope.objects_selected = true;
    //$scope.check_all_domains = true;
    //$scope.objects_selected = angular.copy($scope.emp);
   //angular.copy($scope.emp, $scope.objects_selected);
};




LoadEmpDepts();
function LoadEmpDepts()
{
    Assignments.getempdepts().then (function (response){

        $scope.empdepts = (response.data);
        console.log($scope.empdepts);
     })
}


$scope.selectedRow1 = null;  // initialize our variable to null
$scope.setClickedRow1 = function (employee) {  //function that sets the value of selectedRow to current index
    $scope.selectedRow1 = employee;
}






$scope.save = function()
{

}

});

enter image description here

}

提前致谢

1 个答案:

答案 0 :(得分:0)

<table>
                <tr ng-repeat="e in empdepts | groupBy:'dep_LDesc'">
                    <td>
                        <label ng-click="showContent = !showContent"></label>
                        <details ng-open="showContent">
                            <summary><input type="checkbox" ng-model="chk"  /> {{e[0].dep_LDesc}}</summary> 

                            <div ng-repeat="employee in e">
                                <input type="checkbox" ng-checked="chk"> {{employee.Sname}} 
                            </div>
                        </details>
                    </td>
                </tr>
            </table>