Created
December 11, 2014 01:52
-
-
Save niisar/d9480ebda946c459e192 to your computer and use it in GitHub Desktop.
Directives Which Wraps Elements Via Transclusion
This file contains hidden or 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 xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<script src="js/angular.js"></script> | |
<script> | |
myapp = angular.module("myapp", []); | |
myapp.directive('mytransclude', function () { | |
var directive = {}; | |
directive.restrict = 'E'; /* restrict this directive to elements */ | |
directive.transclude = true; | |
directive.template = "<div class='myTransclude' ng-transclude></div>"; | |
return directive; | |
}); | |
myapp.controller("MyController", function ($scope, $http) { | |
$scope.firstName = "nisar"; | |
}); | |
</script> | |
<title></title> | |
</head> | |
<body ng-app="myapp" ng-controller="MyController"> | |
<mytransclude>This is a transcluded directive {{firstName}}</mytransclude> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment