<!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>
<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>