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

Directive: transclude in conjuction with terminal #6072

Closed
IlanFrumer opened this issue Jan 31, 2014 · 1 comment
Closed

Directive: transclude in conjuction with terminal #6072

IlanFrumer opened this issue Jan 31, 2014 · 1 comment

Comments

@IlanFrumer
Copy link

I have tried to understand what's the difference between this:

{ 
    translcude: 'element',
    terminal: true 
}

And this:

{
    translcude: 'element',
    terminal: false
}

I made a plunker: http://plnkr.co/edit/yryUHelOMW0gITotKiC7?p=preview
It seems that the contents are pre-compiled on both cases so I though terminal: true just get ignored when transclude is used.

Then I saw that these directives: ngIf , ngInclude , ngRepeat all use:
{ trasclude:'element', terminal:true }.
while other directives like ngSwitch , ngSwitchWhen only use:
{ translcude:'element }' without a terminal option.

Now I want a clarification to what are the use cases of these two options in conjunction.

Let say I have a piece of DOM:

<div ng-repeat="item in items">
   {{ item }}
</div>

Even if $scope.items = [] the contents get compiled before any clones are linked.

I currently develop a module which provides directives that show/hide contents based on media queries ( inspired by zurb foundation interchange), If the media query is not matched then the contents stay out of the DOM ( like ngIf). here is the repo: https://github.com/IlanFrumer/angular-match-media

What I suggest is that the behavior of transclude and terminal together would be to defer compilation and lazy compile it on the first time $transclude is called inside the linking function.
If no clones are needed the contents will never get compiled.

Thanks!

@gkalpak
Copy link
Member

gkalpak commented Jul 5, 2016

What I suggest is that the behavior of transclude and terminal together would be to defer compilation and lazy compile it on the first time $transclude is called

This issue is pretty old, but in case anyone is still watching this:
Since 652b83e (v1.5.0-beta.1) the compilation of transcluded content is deferred until necessary.

@gkalpak gkalpak closed this as completed Jul 5, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants