niisar
12/11/2014 - 1:52 AM

Directives Which Wraps Elements Via Transclusion

Directives Which Wraps Elements Via Transclusion

<!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>