1
+ <!DOCTYPE html>
2
+
3
+ < html ng-app ="myApp ">
4
+ < head >
5
+ < meta charset ="utf-8 " />
6
+ < meta name ="viewport " content ="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no " />
7
+ < title > Event - AngularJS Test</ title >
8
+ < style type ="text/css ">
9
+ .test-div {margin : 15px ;padding : 15px ;border : 1px solid # ccc ;}
10
+ </ style >
11
+ </ head >
12
+ < body >
13
+ < div class ="test-div " ng-init ="mySwitch=true ">
14
+ < p >
15
+ < button ng-disabled ="mySwitch "> Click Me</ button >
16
+ </ p >
17
+ < p >
18
+ < input type ="checkbox " ng-model ="mySwitch " /> 禁用
19
+ </ p >
20
+ < p >
21
+ {{mySwitch}}
22
+ </ p >
23
+ </ div >
24
+
25
+ < div class ="test-div " ng-init ="hour=24 ">
26
+ < p ng-show ="hour>=23 "> It's time to sleep!</ p >
27
+ < p ng-hide ="false "> OK!</ p >
28
+ </ div >
29
+
30
+ < div class ="test-div " ng-init ="count=0 ">
31
+ < h2 ng-mouseover ="count = count + 1 "> Mouse over count: {{count}}</ h2 >
32
+ </ div >
33
+
34
+ < div class ="test-div " ng-controller ="myCtrl ">
35
+ < h2 ng-click ="myFunc($event) "> Mouse click count: {{count}}</ h2 >
36
+ </ div >
37
+
38
+ < script type ="text/javascript " src ="static/js/angular-1.5.8.js "> </ script >
39
+ < script type ="text/javascript ">
40
+ /**
41
+ * You can pass the $event object as an argument when calling the function.
42
+ * The $event object contains the browser's event object.
43
+ */
44
+
45
+ var myApp = angular . module ( "myApp" , [ ] ) ;
46
+ myApp . controller ( "myCtrl" , function ( $scope ) {
47
+ $scope . count = 0 ;
48
+ $scope . myFunc = function ( e ) {
49
+ $scope . count ++ ;
50
+ console . log ( "Event Object: " , e )
51
+ } ;
52
+ } ) ;
53
+ </ script >
54
+ </ body >
55
+ </ html >
0 commit comments