day10

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <script type="text/javascript" src="js/angular.js" ></script>
        <script>
        var app=angular.module("myApp",[]);
            app.controller("myctr",function($scope){
                i=0;
                $scope.stus=[{
                    id:1,
                    goods:"华为",
                    name:"张三",
                    shouji:13461677520,
                    chengshi:"北京"
                
                },{
                    id:2,
                    goods:"苹果",
                    name:"李四",
                    shouji:13333333333,
                    chengshi:"上海"
                
                
                
                }];

               

     

                  //全选
                 $scope. All=function(){
                for(var i0;i<$scope.stus.length;i++){
                      $scope.stus[i].ck=$scope.flag;
                }

            }

             //删除
              $scope.sc=function(i){
              $scope.stus.splice(i,1);
          }

                
                
                   //添加
          $scope.add=function(){
              $scope.stus.push({
                    id:3,
                    goods:"vivo",
                    name:"王五",
                    shouji:1333333333,
                    chengshi:"上海"
                       
              })
              }
          
           // 批量删除
            $scope.del=function(){
                //遍历数组
                for(var i=0;i<$scope.stus.length;i++){
                    if($scope.stus[i].ck){
                        $scope.stus.splice(i,1);
                        i--;
                    }
                }
            }
            })
        
                
            
        
        
    
        </script>
    </head>
    <body ng-app="myApp" ng-controller="myctr">
        <button style="background-color:chartreuse" ng-click="add()">新增订单</button>
           <button style="background-color:chartreuse" ng-click="del()">批量删除</button>
        <table border="1px">
               <tr style="background-color: slategray;">
               <td><input type="checkbox" ng-model="flag" ng-click="All()">
                 <td>ID</td>
                 <td>商品名</td>    
                 <td>用户名</td>    
                 <td>手机号</td>      
                 <td>城市</td>    
                 <td>操作</td>     
                   
                 
             </tr>
             <tr ng-repeat=" s in stus">
                 
              <td><input type="checkbox" ng-model="s.ck"></td>
               <td>{{s.id}}</td>    
                <td>{{s.goods}}</td>    
                 <td>{{s.name}}</td>    
                 <td>{{s.shouji}}</td>   
                  <td>{{s.chengshi}}</td>    
                 <td><button ng-click="sc($index)"  style="background-color: orange;">删除</button></td>
 
                  
             </tr>
        </table>
    </body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值