Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 440be33

Browse files
committed
test($compile): transcludeFn is available in compile of templateUrl directive
1 parent 56c6021 commit 440be33

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

Diff for: test/ng/compileSpec.js

+29
Original file line numberDiff line numberDiff line change
@@ -4057,6 +4057,35 @@ describe('$compile', function() {
40574057
});
40584058
});
40594059

4060+
4061+
it('should expose transcludeFn in compile fn even for templateUrl', function() {
4062+
module(function() {
4063+
directive('transInCompile', valueFn({
4064+
transclude: true,
4065+
// template: '<div class="foo">whatever</div>',
4066+
templateUrl: 'foo.html',
4067+
compile: function(_, __, transclude) {
4068+
return function(scope, element) {
4069+
transclude(scope, function(clone, scope) {
4070+
element.html('');
4071+
element.append(clone);
4072+
});
4073+
};
4074+
}
4075+
}));
4076+
});
4077+
4078+
inject(function($compile, $rootScope, $templateCache) {
4079+
$templateCache.put('foo.html', '<div class="foo">whatever</div>');
4080+
4081+
compile('<div trans-in-compile>transcluded content</div>');
4082+
$rootScope.$apply();
4083+
4084+
expect(trim(element.text())).toBe('transcluded content');
4085+
});
4086+
});
4087+
4088+
40604089
it('should make the result of a transclusion available to the parent directive in post-linking phase' +
40614090
'(template)', function() {
40624091
module(function() {

0 commit comments

Comments
 (0)