Created
November 5, 2014 12:08
-
-
Save stevenh77/66d69ea5cdce904317d0 to your computer and use it in GitHub Desktop.
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 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