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

fix(sticky): compile cloned element in the same scope #7151

Closed

Conversation

devversion
Copy link
Member

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

@EladBezalel EladBezalel added the needs: manual testing This issue or PR needs to have some manual testing and verification done label Feb 13, 2016
@EladBezalel
Copy link
Member

Code LGTM

@devversion closing #4979?

@EladBezalel EladBezalel self-assigned this Feb 13, 2016
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
@devversion
Copy link
Member Author

@EladBezalel Yep, just referenced now :)

@ThomasBurleson ThomasBurleson added pr: merge ready This PR is ready for a caretaker to review and removed needs: manual testing This issue or PR needs to have some manual testing and verification done labels Feb 15, 2016
@ThomasBurleson ThomasBurleson added this to the 1.0.6 milestone Feb 15, 2016
@SriramaDanturthi
Copy link

this is missing

MdSticky.$inject = ["$document", "$mdConstant", "$$rAF", "$mdUtil", "$compile"];

@devversion
Copy link
Member Author

@Sriram143 No need, this will be automatically added through the build process, using ngAnnotate.

@SriramaDanturthi
Copy link

@devversion Thanks for the update.

@david-meza
Copy link

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, md-icon)? Thank you.

@devversion
Copy link
Member Author

@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 compilation of the cloned element is required, to reapply the specified scope to the cloned element.

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 controllers / directives back to the cloned element.

ThomasBurleson pushed a commit that referenced this pull request Feb 23, 2016
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

  Closes #7151
@devversion devversion deleted the fix/sticky-cloned-scope branch April 19, 2016 19:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pr: merge ready This PR is ready for a caretaker to review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants