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

fix($compile): allow access to the controllers of transcluded elements f... #4959

Closed
wants to merge 2 commits into from

Conversation

tbosch
Copy link
Contributor

@tbosch tbosch commented Nov 14, 2013

...rom child elements.

Additional API (backwards compatible)

  • Injects $transclude (see directive controllers) as 5th argument to directive link functions.
  • $transclude takes an optional scope as first parameter that overrides the
    bound scope.

Deprecations:

  • transclude parameter of directive compile functions (use the new parameter for link functions instead).

Refactorings:

  • Don't use comment node to temporarily store controllers
  • ngIf, ngRepeat, ... now all use $transclude

Closes #4935.

@@ -1083,9 +1094,9 @@ function $CompileProvider($provide) {
* @returns {Function}
*/
function groupElementsLinkFnWrapper(linkFn, attrStart, attrEnd) {
return function(scope, element, attrs, controllers) {
return function(scope, element, attrs, controllers, $transclude) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

call it just transclude

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or transcludeFn

…s from child elements.

Additional API (backwards compatible)
- Injects `$transclude` (see directive controllers) as 5th argument to directive link functions.
- `$transclude` takes an optional scope as first parameter that overrides the
  bound scope.

Deprecations:
- `transclude` parameter of directive compile functions (use the new parameter for link functions instead).

Refactorings:
- Don't use comment node to temporarily store controllers
- `ngIf`, `ngRepeat`, ... now all use `$transclude`

Closes angular#4935.
@tbosch
Copy link
Contributor Author

tbosch commented Nov 15, 2013

@vojtajina Implemented all changes we discussed. Also changed the docs: I am not sure if this is the right way to mark deprecated arguments (third argument to the compile function)...

@vojtajina
Copy link
Contributor

@tbosch thanks a bunch, great work!

I made a couple of little changes and merged it in as 90f8707.

I don't like how we wrap/bind the transcludeFn many times (first we bind it to the proper scope, and then again to "current controllers"), however I don't wanna make bigger changes it now. The compiler code is too scary ;-)

@vojtajina vojtajina closed this Nov 15, 2013
@tbosch tbosch deleted the transclude-access-controller branch December 4, 2013 18:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants