Last active
October 18, 2015 06:20
-
-
Save thesabbir/4d8127beb9837b356980 to your computer and use it in GitHub Desktop.
Angular Directive Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var App = angular.module("App",[]); | |
App.controller('main',['$scope', function($scope){ | |
$scope.message="Welcome to Tiny App"; | |
$scope.box = { "content" : "This is a Box "}; | |
}]); | |
App.directive('boxy', function() { | |
return { | |
restrict: 'E', | |
template: '<div class="box">{{box.content}}</div>' | |
}; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html ng-app="App"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Tiny App</title> | |
<link rel="stylesheet" type="text/css" href="style.css"> | |
</head> | |
<body ng-controller="main"> | |
{{message}} | |
<boxy></boxy> | |
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script> | |
<script src='app.js'></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.box { | |
height:100px; | |
width:100px; | |
display:block; | |
background:#aaa; | |
padding: 30px; | |
margin: 5px; | |
text-align: center; | |
vertical-align: middle; | |
line-height:100px; | |
box-shadow:1px 1px 5px #000; | |
color:#eee; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment