Skip to content

Commit d9e6515

Browse files
committed
basic useful behaviours
1 parent 552ae91 commit d9e6515

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

03-2-directives.html

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>directives</title>
5+
<style>
6+
*{font-family: Tahoma; font-size: 1em;}#wrapper{width:100%;};
7+
#inner{width:50%; margin:0 auto; border:solid black 1px;};
8+
</style>
9+
10+
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.17/angular.min.js"></script>
11+
12+
<script>
13+
var app = angular.module("usefulDirectives", []);
14+
15+
app.directive("enter", function(){
16+
//by default this is of restrict:'A'
17+
return function(scope, element){
18+
element.bind("mouseenter", function(){
19+
console.log("Entered!");
20+
});
21+
};
22+
});
23+
24+
app.directive("leave", function(){
25+
//by default this is of restrict:'A'
26+
return function(scope, element){
27+
element.bind("mouseleave", function(){
28+
console.log("Left!");
29+
});
30+
};
31+
});
32+
33+
</script>
34+
35+
</head>
36+
<body ng-app="usefulDirectives">
37+
<div enter leave>Content</div>
38+
</body>
39+
</html>

0 commit comments

Comments
 (0)