diff options
| author | Chirayu Krishnappa | 2013-08-09 19:56:10 -0700 | 
|---|---|---|
| committer | Igor Minar | 2013-08-12 10:36:25 -0700 | 
| commit | c173ca412878d537b18df01f39e400ea48a4b398 (patch) | |
| tree | 1c148b33ac230f82efdc25e31cfd91cbcf9f615c /src/ng | |
| parent | 2430347ece2f7a74a35d3ab0095ecc895884670e (diff) | |
| download | angular.js-c173ca412878d537b18df01f39e400ea48a4b398.tar.bz2 | |
fix($compile): correct controller instantiation for async directives
This fixes regression introduced by #3514 (5c560117) - this commit is being
reverted here and a better fix is included.
The regression caused the controller to be instantiated before the isolate scope
was initialized.
Closes #3493
Closes #3482
Closes #3537
Closes #3540
Diffstat (limited to 'src/ng')
| -rw-r--r-- | src/ng/compile.js | 23 | 
1 files changed, 12 insertions, 11 deletions
diff --git a/src/ng/compile.js b/src/ng/compile.js index b07a47e1..7a2ee4e7 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -782,6 +782,13 @@ function $CompileProvider($provide) {          directiveName = directive.name; +        if (directiveValue = directive.controller) { +          controllerDirectives = controllerDirectives || {}; +          assertNoDuplicate("'" + directiveName + "' controller", +              controllerDirectives[directiveName], directive, $compileNode); +          controllerDirectives[directiveName] = directive; +        } +          if (directiveValue = directive.transclude) {            assertNoDuplicate('transclusion', transcludeDirective, directive, $compileNode);            transcludeDirective = directive; @@ -870,13 +877,6 @@ function $CompileProvider($provide) {            }          } -        if (!directive.templateUrl && directive.controller) { -          controllerDirectives = controllerDirectives || {}; -          assertNoDuplicate("'" + directiveName + "' controller", -              controllerDirectives[directiveName], directive, $compileNode); -          controllerDirectives[directiveName] = directive; -        } -          if (directive.terminal) {            nodeLinkFn.terminal = true;            terminalPriority = Math.max(terminalPriority, directive.priority); @@ -1152,7 +1152,7 @@ function $CompileProvider($provide) {            origAsyncDirective = directives.shift(),            // The fact that we have to copy and patch the directive seems wrong!            derivedSyncDirective = extend({}, origAsyncDirective, { -            templateUrl: null, transclude: null, scope: null, replace: null +            controller: null, templateUrl: null, transclude: null, scope: null, replace: null            }),            templateUrl = (isFunction(origAsyncDirective.templateUrl))                ? origAsyncDirective.templateUrl($compileNode, tAttrs) @@ -1208,9 +1208,10 @@ function $CompileProvider($provide) {                replaceWith(linkRootElement, jqLite(beforeTemplateLinkNode), linkNode);              } -            afterTemplateNodeLinkFn(function() { -              beforeTemplateNodeLinkFn(afterTemplateChildLinkFn, scope, linkNode, $rootElement, controller); -            }, scope, linkNode, $rootElement, controller); +            afterTemplateNodeLinkFn( +              beforeTemplateNodeLinkFn(afterTemplateChildLinkFn, scope, linkNode, $rootElement, controller), +              scope, linkNode, $rootElement, controller +            );            }            linkQueue = null;          }).  | 
