File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 13
13
var app = angular . module ( "myApp" , [ ] ) ;
14
14
app . directive ( "calculator" , function ( ) {
15
15
return {
16
- restrict : "E" ,
16
+ restrict : "E" , //E for element
17
17
template :"<img src='http://www.stat.osu.edu/~stated/images/calculator.gif'>"
18
18
} ;
19
19
} ) ;
20
+
21
+ app . directive ( "leak" , function ( ) {
22
+ return {
23
+ restrict :"A" , //A for attribute
24
+ link :function ( ) {
25
+ alert ( "spray!" ) ;
26
+ }
27
+ }
28
+ } ) ;
20
29
</ script >
21
30
22
31
</ head >
23
32
< body ng-app ="myApp ">
24
33
< div id ="wrapper ">
25
34
< calculator > </ calculator > < br />
26
- < calculator > </ calculator >
35
+ <!--Here we give our calculator attribute the leak attribute which executes the linking function.
36
+ We could have just as well added the attribute to any other element-->
37
+ < calculator leak > </ calculator >
27
38
</ div >
28
39
</ body >
29
40
</ html >
You can’t perform that action at this time.
0 commit comments