Skip to content

Instantly share code, notes, and snippets.

@stevenh77
Created November 5, 2014 12:08
Show Gist options
  • Save stevenh77/66d69ea5cdce904317d0 to your computer and use it in GitHub Desktop.
Save stevenh77/66d69ea5cdce904317d0 to your computer and use it in GitHub Desktop.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Transclude</title>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.1/angular.min.js"></script>
</head>
<body ng-app="transcludeExample">
<script>
angular.module('transcludeExample', [])
.directive('pane', function(){
return {
restrict: 'E',
transclude: true,
scope: { title:'@' },
template: '<div>' +
'<h1>{{title}}</h1>' +
'<ng-transclude></ng-transclude>' +
'</div>'
};
})
.controller('ExampleController', ['$scope', function($scope) {
$scope.title = 'Transfer and Include';
$scope.text = 'Takes the HTML within your directive and includes it in your directive template';
}]);
</script>
<div ng-controller="ExampleController">
<input ng-model="title"><br>
<textarea ng-model="text"></textarea> <br/>
<pane title="{{title}}">{{text}}</pane>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment