14
14
15
15
app . directive ( "enter" , function ( ) {
16
16
//by default this is of restrict:'A'
17
- return function ( scope , element ) {
17
+ return function ( scope , element , attrs ) {
18
18
element . bind ( "mouseenter" , function ( ) {
19
- console . log ( "Entered!" ) ;
19
+ element . removeClass ( attrs . class )
20
+ element . addClass ( attrs . enter ) ;
20
21
} ) ;
21
22
} ;
22
23
} ) ;
23
24
24
25
app . directive ( "leave" , function ( ) {
25
26
//by default this is of restrict:'A'
26
- return function ( scope , element ) {
27
+ return function ( scope , element , attrs ) {
27
28
element . bind ( "mouseleave" , function ( ) {
28
- console . log ( "Left!" ) ;
29
+ element . removeClass ( attrs . class ) ;
30
+ element . addClass ( attrs . leave ) ;
29
31
} ) ;
30
32
} ;
31
33
} ) ;
32
34
33
35
</ script >
34
36
37
+ <!--The following is style we are going to use in our manipulations-->
38
+ < style >
39
+ .green {
40
+ background-color : green;
41
+ border : 1px solid black;
42
+ }
43
+ .hover {
44
+ background-color : red;
45
+ border : 1px solid black;
46
+ }
47
+ .warnOrange {
48
+ background-color : orange;
49
+ border : 1px solid black;
50
+ }
51
+ </ style >
35
52
</ head >
36
53
< body ng-app ="usefulDirectives ">
37
- < div enter leave > Content</ div >
54
+ < div enter ="hover " leave ="warnOrange " class ="warnOrange "> THIS IS VERY IMPORTANT! ROLL OVER!</ div > < br />
55
+ < div enter ="hover " leave ="warnOrange " class ="green "> This is not important until you roll over!</ div >
38
56
</ body >
39
57
</ html >
0 commit comments