-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix(sticky): compile cloned element in the same scope #7151
Conversation
Code LGTM @devversion closing #4979? |
Currently never apply a scope to the cloned element, which will cause problems with directives, which have bindings in their template. Also added the documentation for a common use-case Closes angular#4979
25c3b17
to
74e58a4
Compare
@EladBezalel Yep, just referenced now :) |
this is missing MdSticky.$inject = ["$document", "$mdConstant", "$$rAF", "$mdUtil", "$compile"]; |
@Sriram143 No need, this will be automatically added through the build process, using ngAnnotate. |
@devversion Thanks for the update. |
Thanks for the contribution. I am running into this issue at the moment, so the PR is appreciated. One question I have is will this still work with more complex templates that use transclusion and/or inner components which have to compile (say, |
@david-meza The new changes won't change anything huge in the service. As mentioned in the documentation, we will compile the cloned directive by default into the provided scope. At this point there can be problems with already-compiled elements which change their structure during compilation. So for example if I use a directive template like: <my-directive>
Hello
</my-directive> and the actual directive will modify the element tree, to look like this: <my-directive>
<div class="wrap-container">
Hello
</div>
</my-directive> then we'll have a problem with compiling that back into the element tree. The If this is your case, that the directive can't detect the actual content anymore - then you have to use the plain template as shown in the example. So finally I can say, this is a good question and isn't easy to solve, because we have no way to detect the initial DOM structure or copying all the needed |
Currently never apply a scope to the cloned element, which will cause problems with directives, which have bindings in their template.
Also added the documentation for a common use-case
Closes #4979