|
620 | 620 | *
|
621 | 621 | *
|
622 | 622 | * @param {string|DOMElement} element Element or HTML string to compile into a template function.
|
623 |
| - * @param {function(angular.Scope, cloneAttachFn=)} transclude function available to directives. |
| 623 | + * @param {function(angular.Scope, cloneAttachFn=)} transclude function available to directives - DEPRECATED. |
| 624 | + * |
| 625 | + * <div class="alert alert-error"> |
| 626 | + * **Note:** Passing a `transclude` function to the $compile function is deprecated, as it |
| 627 | + * e.g. will not use the right outer scope. Please pass the transclude function as a |
| 628 | + * `parentBoundTranscludeFn` to the link function instead. |
| 629 | + * </div> |
| 630 | + * |
624 | 631 | * @param {number} maxPriority only apply directives lower than given priority (Only effects the
|
625 | 632 | * root element(s), not their children)
|
626 |
| - * @returns {function(scope, cloneAttachFn=)} a link function which is used to bind template |
| 633 | + * @returns {function(scope, cloneAttachFn=, options=)} a link function which is used to bind template |
627 | 634 | * (a DOM element/tree) to a scope. Where:
|
628 | 635 | *
|
629 | 636 | * * `scope` - A {@link ng.$rootScope.Scope Scope} to bind to.
|
|
635 | 642 | * * `clonedElement` - is a clone of the original `element` passed into the compiler.
|
636 | 643 | * * `scope` - is the current scope with which the linking function is working with.
|
637 | 644 | *
|
| 645 | + * * `options` - An optional object hash with linking options. If `options` is provided, then the following |
| 646 | + * keys may be used to control linking behavior: |
| 647 | + * |
| 648 | + * * `parentBoundTranscludeFn` - the transclude function made available to |
| 649 | + * directives; if given, it will be passed through to the link functions of |
| 650 | + * directives found in `element` during compilation. |
| 651 | + * * `transcludeControllers` - an object hash with keys that map controller names |
| 652 | + * to controller instances; if given, it will make the controllers |
| 653 | + * available to directives. |
| 654 | + * * `futureParentElement` - defines the parent to which the `cloneAttachFn` will add |
| 655 | + * the cloned elements; only needed for transcludes that are allowed to contain non html |
| 656 | + * elements (e.g. SVG elements). See also the directive.controller property. |
| 657 | + * |
638 | 658 | * Calling the linking function returns the element of the template. It is either the original
|
639 | 659 | * element passed in, or the clone of the element if the `cloneAttachFn` is provided.
|
640 | 660 | *
|
@@ -1153,8 +1173,14 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
1153 | 1173 | maxPriority, ignoreDirective, previousCompileContext);
|
1154 | 1174 | compile.$$addScopeClass($compileNodes);
|
1155 | 1175 | var namespace = null;
|
1156 |
| - return function publicLinkFn(scope, cloneConnectFn, parentBoundTranscludeFn, transcludeControllers, futureParentElement){ |
| 1176 | + return function publicLinkFn(scope, cloneConnectFn, options){ |
1157 | 1177 | assertArg(scope, 'scope');
|
| 1178 | + |
| 1179 | + options = options || {}; |
| 1180 | + var parentBoundTranscludeFn = options.parentBoundTranscludeFn, |
| 1181 | + transcludeControllers = options.transcludeControllers, |
| 1182 | + futureParentElement = options.futureParentElement; |
| 1183 | + |
1158 | 1184 | if (!namespace) {
|
1159 | 1185 | namespace = detectNamespaceForChildElements(futureParentElement);
|
1160 | 1186 | }
|
@@ -1324,7 +1350,11 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
1324 | 1350 | transcludedScope.$$transcluded = true;
|
1325 | 1351 | }
|
1326 | 1352 |
|
1327 |
| - return transcludeFn(transcludedScope, cloneFn, previousBoundTranscludeFn, controllers, futureParentElement); |
| 1353 | + return transcludeFn(transcludedScope, cloneFn, { |
| 1354 | + parentBoundTranscludeFn: previousBoundTranscludeFn, |
| 1355 | + transcludeControllers: controllers, |
| 1356 | + futureParentElement: futureParentElement |
| 1357 | + }); |
1328 | 1358 | };
|
1329 | 1359 |
|
1330 | 1360 | return boundTranscludeFn;
|
|
0 commit comments