From ed50b4775d7d49a44d3d39d103aa4f50d3442174 Mon Sep 17 00:00:00 2001 From: Stephen Feest Date: Wed, 17 Aug 2016 21:35:36 +0100 Subject: [PATCH] Add $transclude function tests These tests try to exercise the different ways that the $transclude can be called including: + With and without specifying the scope explicitly + With and without a clone attach function + With and without specifying the future parent + Using the default and named transclude slots --- angularjs/angular-tests.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts index ef3e29b4c8..07f67a7375 100644 --- a/angularjs/angular-tests.ts +++ b/angularjs/angular-tests.ts @@ -867,6 +867,26 @@ angular.module('docsTabsExample', []) }; }); +angular.module('multiSlotTranscludeExample', []) + .directive('dropDownMenu', function() { + return { + transclude: { + button: 'button', + list: 'ul', + }, + link: function(scope, element, attrs, ctrl, transclude) { + // without scope + transclude().appendTo(element); + transclude(clone => clone.appendTo(element)); + + // with scope + transclude(scope, clone => clone.appendTo(element)); + transclude(scope, clone => clone.appendTo(element), element, 'button'); + transclude(scope, null, element, 'list').addClass('drop-down-list').appendTo(element); + } + }; + }); + angular.module('componentExample', []) .component('counter', { require: {'ctrl': '^ctrl'},