diff options
| author | Igor Minar | 2012-03-08 15:00:38 -0800 |
|---|---|---|
| committer | Igor Minar | 2012-03-08 22:29:34 -0800 |
| commit | f54db2ccda399f2677e4ca7588018cb31545a2b4 (patch) | |
| tree | 29ef2f8f834544c84cea1a82e3d08679358fb992 /src/directive/ngTransclude.js | |
| parent | dd7b0f56fcd9785f7fccae8c4f088a8f3e7b125e (diff) | |
| download | angular.js-f54db2ccda399f2677e4ca7588018cb31545a2b4.tar.bz2 | |
chore(directives,widgets): reorg the code under directive/ dir
Diffstat (limited to 'src/directive/ngTransclude.js')
| -rw-r--r-- | src/directive/ngTransclude.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/directive/ngTransclude.js b/src/directive/ngTransclude.js new file mode 100644 index 00000000..16587f30 --- /dev/null +++ b/src/directive/ngTransclude.js @@ -0,0 +1,58 @@ +'use strict'; + +/** + * @ngdoc directive + * @name angular.module.ng.$compileProvider.directive.ng:transclude + * + * @description + * Insert the transcluded DOM here. + * + * @element ANY + * + * @example + <doc:example module="transclude"> + <doc:source> + <script> + function Ctrl($scope) { + $scope.title = 'Lorem Ipsum'; + $scope.text = 'Neque porro quisquam est qui dolorem ipsum quia dolor...'; + } + + angular.module('transclude', []) + .directive('pane', function(){ + return { + restrict: 'E', + transclude: true, + scope: 'isolate', + locals: { title:'bind' }, + template: '<div style="border: 1px solid black;">' + + '<div style="background-color: gray">{{title}}</div>' + + '<div ng-transclude></div>' + + '</div>' + }; + }); + </script> + <div ng:controller="Ctrl"> + <input ng:model="title"><br> + <textarea ng:model="text"></textarea> <br/> + <pane title="{{title}}">{{text}}</pane> + </div> + </doc:source> + <doc:scenario> + it('should have transcluded', function() { + input('title').enter('TITLE'); + input('text').enter('TEXT'); + expect(binding('title')).toEqual('TITLE'); + expect(binding('text')).toEqual('TEXT'); + }); + </doc:scenario> + </doc:example> + * + */ +var ngTranscludeDirective = ngDirective({ + controller: ['$transclude', '$element', function($transclude, $element) { + $transclude(function(clone) { + $element.append(clone); + }); + }] +}); |
