Skip to content

Commit

Permalink
adds attribute directives
Browse files Browse the repository at this point in the history
  • Loading branch information
zafarali committed Jun 17, 2014
1 parent fa0b6c1 commit 403aad1
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions 03-1-directives.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,28 @@
var app = angular.module("myApp", []);
app.directive("calculator", function(){
return {
restrict : "E",
restrict : "E",//E for element
template:"<img src='http://www.stat.osu.edu/~stated/images/calculator.gif'>"
};
});

app.directive("leak", function(){
return {
restrict:"A",//A for attribute
link:function(){
alert("spray!");
}
}
});
</script>

</head>
<body ng-app="myApp">
<div id="wrapper">
<calculator></calculator><br />
<calculator></calculator>
<!--Here we give our calculator attribute the leak attribute which executes the linking function.
We could have just as well added the attribute to any other element-->
<calculator leak></calculator>
</div>
</body>
</html>

0 comments on commit 403aad1

Please sign in to comment.