Directive ng-transclude

by Suman Kumar

HTML

<div ng-app="myApp" ng-controller="myCtrl">
  <div ng-repeat="movie in movies">
  <div my-dir title={{movie}}>
    Movie Title :
  </div>
  </div>
</div>

JavaScript

var myApp = angular.module('myApp',[]);

myApp.controller('myCtrl', function($scope){
$scope.movies = ['Gang Leader', 'JVAS', 'Chudalani Undi'];
});

myApp.directive('myDir', function(){
return{
	transclude:true,
	template:'<span ng-transclude></span>',
  link:function(scope,element,attr){
  	element.append("<strong>"+attr.title+"</strong>");
  };
}
});