账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    angular 求解
    24
    0
    <!DOCTYPE html >
    <html lang="en" ng-app="app">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <style>
            .cc{
                border: 1px solid #ccc;
                border-collapse: collapse;
            }
            .cc td{
                text-align: center;
                padding: 6px 6px;
                border: 1px solid #ccc;
                height: 20px;
            }
    
        </style>
    
    
    </head>
    <body ng-controller="siteCtrl">
        <table border="1" cellpadding="0" cellspacing="0" class="cc" >
            <tr>
                <td>组</td>
                <td>组下项</td>
            </tr>
    
            <tr ng-repeat="item1 in dataList">
                <td>
                    <input type="checkbox" ng-model="item1.ProState" ng-click="selectItem(item1.ProState,item1.ProName)">
                {{item1.ProList}}
                </td>
                <td>
                <table border="0" cellpadding="0" cellspacing="0">
                    <tr ng-repeat="item in item1.data">
                    <td><input type="checkbox"  ng-model="item.state" name="" ng-checked="item.state"></td>
                    <td>{{item.Name}}</td>
                    <td>{{item.Url}}</td>
                    <td>{{item.Email}}</td>
                        <td><button ng-click="add(item.ProName,$index)">增加</button></td>
                    </tr>
                </table>
                </td>
            </tr>
        </table>
        <!--<script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>-->
        <script type="text/javascript" src="js/angular.min.js"></script>
    <script>
        var app = angular.module('app', []);
        app.controller('siteCtrl',function ($scope,$http) {
    
            $scope.dataList =[
                {
                    "ProList":"a1",
                    "ProName":"g1",
                    "ProState":false,
                    "data" :[
                                {
                                "Name":"john1",
                                "Url":"ImJohn.cn",
                                "Email":"go",
                                "state":true,
                                "ProName":"g1"
                                },
                                {
                                    "Name":"john1",
                                    "Url":"ImJohn.cn",
                                    "Email":"go",
                                    "state":false,
                                    "ProName":"g1"
                                },
                                {
                                    "Name":"john1",
                                    "Url":"ImJohn.cn",
                                    "Email":"go",
                                    "state":false,
                                    "ProName":"g1"
                                }
                            ]
                },
                {
                    "ProList":"a2",
                    "ProName":"g2",
                    "ProState":false,
                    "data":[
                        {
                            "Name":"john2",
                            "Url":"ImJohn.cn",
                            "Email":"go",
                            "state":false,
                            "ProName":"g2"
                        },
                        {
                            "Name":"john2",
                            "Url":"ImJohn.cn",
                            "Email":"go",
                            "state":false,
                            "ProName":"g2"
                        },
                        {
                            "Name":"john2",
                            "Url":"ImJohn.cn",
                            "Email":"go",
                            "state":false,
                            "ProName":"g2"
                        }
                    ]
                },
                {
                    "ProList":"a3",
                    "ProName":"g3",
                    "ProState":false,
                    "data":[
                        {
                            "Name":"john3",
                            "Url":"ImJohn.cn",
                            "Email":"go",
                            "state":false,
                            "ProName":"g3"
                        },
                        {
                            "Name":"john3",
                            "Url":"ImJohn.cn",
                            "Email":"go",
                            "state":false,
                            "ProName":"g3"
                        },
                        {
                            "Name":"john3",
                            "Url":"ImJohn.cn",
                            "Email":"go",
                            "state":false,
                            "ProName":"g3"
                        }
                    ]
                }
            ]
    
            $scope.selectItem=function (vf,Pro) {
                if(!vf){
                    $scope.dataList.map(function (item) {
                        $scope.idata =item.data;
                        $scope.idata.map(function(tem){
                            if(tem.ProName==Pro){
                                tem.state=true;
                            }
                            return item;
                        });
                    });
                }else{
                    $scope.dataList.map(function (item) {
                        $scope.idata =item.data;
                        $scope.idata.map(function(tem){
                            if(tem.ProName==Pro){
                                tem.state=false;
                            }
                            return item;
                        });
                    });
                }
    
            };
            $scope.add=function(item,index){
                var map = {
                    "Name":item.Name,
                    "Url":item.Url,
                    "Email":item.Email,
                    "state":true,
                    "ProName":item.ProName
                };
    
                $scope.dataList.map(function (item3) {
                    $scope.idata =item3.data;
                    $scope.idata.map(function(tem){
                        if(tem.ProName==item){
                            $scope.tdata =[];
                            $scope.tdata.push(tem)
                        }
                        $scope.tdata.splice(index+1,0,map);
                        item = $scope.tdata;
                        return item;
                    });
                });
    
            }
    
        })
    
    </script>
    </body>
    </html>

    组下项 全部选中时 组选中 组下项全不选 组不选 这个用state怎么做 add函数 添加行怎么直接拿item当前项下的数据添加

    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部