全选和反选
BUG:当鼠标点击其中一个选项后,在点击全选按钮,该选项失效
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>
</head>
<body>
<div ng-app="hd" ng-controller="ctrl">
<input type="text" ng-model="user.email" ng-readonly="user.uid"/>
<hr/>
<table>
<tr>
<td>
<input type="checkbox" ng-model="all" >
<span ng-bind="!all?'全选':'取消'"></span>
</td>
<td>名称</td>
<td>网址</td>
</tr>
<tr ng-repeat="v in data">
<td><input type="checkbox" ng-model="all"></td>
<td>{{v.name}}</td>
<td>{{v.url}}</td>
</tr>
</table>
</div>
<script>
var m=angular.module('hd',[]);
m.controller('ctrl',['$scope',function($scope){
$scope.user={name:'百度',uid:1,email:'11111@qq.com'};
$scope.data=[{name:'百度',url:'baidu.com'},
{name:'新浪',url:'sina.com'},
{name:'搜狐',url:'souhu.com'},
{name:'博客',url:'blog.com'}
];
}]);
</script>
</body>
</html>