|
622 | 622 | *
|
623 | 623 | *
|
624 | 624 | * @param {string|DOMElement} element Element or HTML string to compile into a template function.
|
625 |
| - * @param {function(angular.Scope, cloneAttachFn=)} transclude function available to directives. |
| 625 | + * @param {function(angular.Scope, cloneAttachFn=)} transclude function available to directives - DEPRECATED. |
| 626 | + * |
| 627 | + * <div class="alert alert-error"> |
| 628 | + * **Note:** Passing a `transclude` function to the $compile function is deprecated, as it |
| 629 | + * e.g. will not use the right outer scope. Please pass the transclude function as a |
| 630 | + * `parentBoundTranscludeFn` to the link function instead. |
| 631 | + * </div> |
| 632 | + * |
626 | 633 | * @param {number} maxPriority only apply directives lower than given priority (Only effects the
|
627 | 634 | * root element(s), not their children)
|
628 |
| - * @returns {function(scope, cloneAttachFn=)} a link function which is used to bind template |
| 635 | + * @returns {function(scope, cloneAttachFn=, options=)} a link function which is used to bind template |
629 | 636 | * (a DOM element/tree) to a scope. Where:
|
630 | 637 | *
|
631 | 638 | * * `scope` - A {@link ng.$rootScope.Scope Scope} to bind to.
|
|
637 | 644 | * * `clonedElement` - is a clone of the original `element` passed into the compiler.
|
638 | 645 | * * `scope` - is the current scope with which the linking function is working with.
|
639 | 646 | *
|
| 647 | + * * `options` - An optional object hash with linking options. If `options` is provided, then the following |
| 648 | + * keys may be used to control linking behavior: |
| 649 | + * |
| 650 | + * * `parentBoundTranscludeFn` - the transclude function made available to |
| 651 | + * directives; if given, it will be passed through to the link functions of |
| 652 | + * directives found in `element` during compilation. |
| 653 | + * * `transcludeControllers` - an object hash with keys that map controller names |
| 654 | + * to controller instances; if given, it will make the controllers |
| 655 | + * available to directives. |
| 656 | + * * `futureParentElement` - defines the parent to which the `cloneAttachFn` will add |
| 657 | + * the cloned elements; only needed for transcludes that are allowed to contain non html |
| 658 | + * elements (e.g. SVG elements). See also the directive.controller property. |
| 659 | + * |
640 | 660 | * Calling the linking function returns the element of the template. It is either the original
|
641 | 661 | * element passed in, or the clone of the element if the `cloneAttachFn` is provided.
|
642 | 662 | *
|
@@ -1155,9 +1175,14 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
1155 | 1175 | maxPriority, ignoreDirective, previousCompileContext);
|
1156 | 1176 | compile.$$addScopeClass($compileNodes);
|
1157 | 1177 | var namespace = null;
|
1158 |
| - return function publicLinkFn(scope, cloneConnectFn, transcludeControllers, parentBoundTranscludeFn, futureParentElement) { |
| 1178 | + return function publicLinkFn(scope, cloneConnectFn, options) { |
1159 | 1179 | assertArg(scope, 'scope');
|
1160 | 1180 |
|
| 1181 | + options = options || {}; |
| 1182 | + var parentBoundTranscludeFn = options.parentBoundTranscludeFn, |
| 1183 | + transcludeControllers = options.transcludeControllers, |
| 1184 | + futureParentElement = options.futureParentElement; |
| 1185 | + |
1161 | 1186 | // When `parentBoundTranscludeFn` is passed, it is a
|
1162 | 1187 | // `controllersBoundTransclude` function (it was previously passed
|
1163 | 1188 | // as `transclude` to directive.link) so we must unwrap it to get
|
@@ -1335,7 +1360,11 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
1335 | 1360 | transcludedScope.$$transcluded = true;
|
1336 | 1361 | }
|
1337 | 1362 |
|
1338 |
| - return transcludeFn(transcludedScope, cloneFn, previousBoundTranscludeFn, controllers, futureParentElement); |
| 1363 | + return transcludeFn(transcludedScope, cloneFn, { |
| 1364 | + parentBoundTranscludeFn: previousBoundTranscludeFn, |
| 1365 | + transcludeControllers: controllers, |
| 1366 | + futureParentElement: futureParentElement |
| 1367 | + }); |
1339 | 1368 | };
|
1340 | 1369 |
|
1341 | 1370 | return boundTranscludeFn;
|
|
0 commit comments