Skip to content

Commit a0636ad

Browse files
committed
demonstrates more useful activity
1 parent d9e6515 commit a0636ad

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

03-2-directives.html

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,44 @@
1414

1515
app.directive("enter", function(){
1616
//by default this is of restrict:'A'
17-
return function(scope, element){
17+
return function(scope, element, attrs){
1818
element.bind("mouseenter", function(){
19-
console.log("Entered!");
19+
element.removeClass(attrs.class)
20+
element.addClass(attrs.enter);
2021
});
2122
};
2223
});
2324

2425
app.directive("leave", function(){
2526
//by default this is of restrict:'A'
26-
return function(scope, element){
27+
return function(scope, element,attrs){
2728
element.bind("mouseleave", function(){
28-
console.log("Left!");
29+
element.removeClass(attrs.class);
30+
element.addClass(attrs.leave);
2931
});
3032
};
3133
});
3234

3335
</script>
3436

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>
3552
</head>
3653
<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>
3856
</body>
3957
</html>

0 commit comments

Comments
 (0)