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
This commit is contained in:
Stephen Feest
2016-08-17 21:35:36 +01:00
parent 6d9768b337
commit ed50b4775d

View File

@@ -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'},