From 413c8b6449404989517f37bb930b88e6c26a18a9 Mon Sep 17 00:00:00 2001 From: Jakub Torbicki Date: Tue, 17 Mar 2015 13:16:33 +0100 Subject: [PATCH 1/2] fix for #11343 - bindToController for multiple directives --- src/ng/compile.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/ng/compile.js b/src/ng/compile.js index 1afd08606e8b..0ae6e52a8a28 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -1960,19 +1960,21 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { newIsolateScopeDirective, isolateScope); } if (elementControllers) { - // Initialize bindToController bindings for new/isolate scopes - var scopeDirective = newIsolateScopeDirective || newScopeDirective; - var bindings; - var controllerForBindings; - if (scopeDirective && elementControllers[scopeDirective.name]) { - bindings = scopeDirective.$$bindings.bindToController; - controller = elementControllers[scopeDirective.name]; - - if (controller && controller.identifier && bindings) { - controllerForBindings = controller; - thisLinkFn.$$destroyBindings = + for (i in elementControllers) { + // Initialize bindToController bindings for new/isolate scopes + var scopeDirective = newIsolateScopeDirective || controllerDirectives[i]; + var bindings; + var controllerForBindings; + if (scopeDirective && elementControllers[scopeDirective.name]) { + bindings = scopeDirective.$$bindings.bindToController; + controller = elementControllers[scopeDirective.name]; + + if (controller && controller.identifier && bindings) { + controllerForBindings = controller; + thisLinkFn.$$destroyBindings = initializeDirectiveBindings(scope, attrs, controller.instance, - bindings, scopeDirective); + bindings, scopeDirective); + } } } for (i in elementControllers) { From bb5fc2fe54bc2888a8ccc1efcbb751b0a1bb7ec1 Mon Sep 17 00:00:00 2001 From: Jakub Torbicki Date: Tue, 17 Mar 2015 15:08:26 +0100 Subject: [PATCH 2/2] fix for #11343 - bindToController for multiple directives. Out of scope variables fix --- src/ng/compile.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/ng/compile.js b/src/ng/compile.js index 0ae6e52a8a28..ae2e124ce880 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -1968,7 +1968,6 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { if (scopeDirective && elementControllers[scopeDirective.name]) { bindings = scopeDirective.$$bindings.bindToController; controller = elementControllers[scopeDirective.name]; - if (controller && controller.identifier && bindings) { controllerForBindings = controller; thisLinkFn.$$destroyBindings = @@ -1976,17 +1975,15 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { bindings, scopeDirective); } } - } - for (i in elementControllers) { controller = elementControllers[i]; var controllerResult = controller(); if (controllerResult !== controller.instance && - controller === controllerForBindings) { + controller === controllerForBindings) { // Remove and re-install bindToController bindings thisLinkFn.$$destroyBindings(); thisLinkFn.$$destroyBindings = - initializeDirectiveBindings(scope, attrs, controllerResult, - bindings, scopeDirective); + initializeDirectiveBindings(scope, attrs, controllerResult, + bindings, scopeDirective); } } }