学习

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="js/angular.min.js"></script>
 <script>
    var app=  angular.module("zhaoapp",[]);
     app.controller("ctrl",function($scope){
      $scope.datas=[{name:'张三',sex:'男',age:25},{name:'李四',sex:'男',age:30}];
      $scope.add=function(){
      $scope.datas.push({name:$scope.uname,sex:$scope.sex,age:20})
      }
          $scope.delet=function(ids){
          $scope.datas.splice(ids, 1);
          }
     });
 </script>
    <style>
      table:hover{
      background: red;
      }
      table tr:hover{
      background: green;
      }
    </style>
</head>
<body ng-app="zhaoapp" ng-controller="ctrl">
 {{datas}}
 <form>
   用户名:<input type="text" ng-model="uname" />
   性别:男<input type="radio" ng-model="sex" value="男" />
     女<input type="radio" ng-model="sex" value="女" />
    <button ng-click="add()">添加</button>
 </form>
   <table border="1"  align="center">
    <tr>
    <th width="100px">编号</th>
    <th width="100px">姓名</th>
    <th width="100px">性别</th>
    <th width="100px">年龄</th>
    <th width="100px" colspan="2">操作</th>
    </tr>
     <tr ng-repeat="a in datas">
        <th>{{$index}}</th>
        <th>{{a.name}} <input ng-model="a.name"ng-show="flag" ng-blur="flag=false"</th>
        <th>{{a.sex}} <input ng-model="a.sex" ng-show="flag" ng-blur="flag=false"</th>
        <th>{{a.age}}</th>
      <th><button ng-click="delet($index)">删除</button></th>
      <th><button ng-click="flag=true">修改</button></th>
     </tr>
   </table>
   
</body>

</html>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值