-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdg.html
45 lines (43 loc) · 1.18 KB
/
dg.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<!DOCTYPE html>
<html lang="en" ng-app="app">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body ng-controller="Ctrl">
<div ng-repeat="item in list">
<button ng-click="item.status=!item.status">获取焦点</button>
<input type="text" watch ng-watch="item.status">
</div>
</body>
<script src="lib/angular.js"></script>
<!--<script src="template/ngWatch.dirctive.js"></script>-->
<script>
var app = angular.module('app',[]).controller('Ctrl',function($scope){
$scope.item=false;
$scope.list = [
{name:"test",status:false},
{name:"test1",status:false},
{name:"test2",status:false},
]
$scope.is = function(){
$scope.item=!$scope.item;
}
})
app.directive('watch',function(){
return {
scope:{
ngWatch:"="
},
link:function(scope,element,attrs){
console.log(element)
scope.$watch('ngWatch',function(a,b){
if(scope.ngWatch){
element[0].focus();
}
})
}
}
})
</script>
</html>