outer-all-check.html 1.6 KB
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8" />
    <title>外部全选</title>
</head>

<body style="padding: 50px;">
    <div ng-app="esNgAntd" ng-controller="mainCtrl">
        <div class="container">
            <antd-table columns="columns" d-source="dataSource" row-selection="rowSelection"></antd-table>
            <antd-checkbox on-change="onChange(event)">全选</antd-checkbox>
        </div>
    </div>
    <script src="https://cdn.staticfile.org/angular.js/1.2.28/angular.min.js"></script>
    <script src="../../dist/ng-antd.js"></script>
    <script>
        angular
            .module("esNgAntd")
            .controller("mainCtrl", function ($scope) {
                $scope.columns = [
                    {
                        title: "AAA",
                        key: "name",
                    },
                ];

                $scope.dataSource = [
                    {
                        id: 1,
                        name: "AAA",
                    },
                    {
                        id: 2,
                        name: "BBB",
                    },
                ];

                $scope.rowSelection = {
                    selectedRowKeys: [0],
                    hideSelectAll: false,
                };

                $scope.onChange = function(event) {
                    if(event.target.checked) {
                        $scope.rowSelection.selectedRowKeys = [0, 1];
                    } else {
                        $scope.rowSelection.selectedRowKeys = [];
                    }
                }
            });
    </script>
</body>

</html>