diff options
| author | jankuca | 2013-08-08 16:04:11 -0700 |
|---|---|---|
| committer | Igor Minar | 2013-08-08 22:58:51 -0700 |
| commit | 9c51d503188efae14b81bd4d6dd7d5a3363f050f (patch) | |
| tree | ade744f2afbc0720302938ce87966097bcb735c6 /src/ng/compile.js | |
| parent | 1c3a46adda358df21e6383113e0ddc499f2cac0c (diff) | |
| download | angular.js-9c51d503188efae14b81bd4d6dd7d5a3363f050f.tar.bz2 | |
fix($compile): always instantiate controllers before pre-link fns run
Controllers should be always instantiated after compile fn runs, but before
pre-link fn runs. This way, controllers are available to pre-link fns that
request them.
Previously this was broken for async directives (directives with templateUrl).
Closes #3493
Closes #3482
Closes #3514
Diffstat (limited to 'src/ng/compile.js')
| -rw-r--r-- | src/ng/compile.js | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/ng/compile.js b/src/ng/compile.js index 04689268..8b7a7674 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -621,13 +621,6 @@ 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; @@ -705,6 +698,13 @@ 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); @@ -962,7 +962,7 @@ function $CompileProvider($provide) { origAsyncDirective = directives.shift(), // The fact that we have to copy and patch the directive seems wrong! derivedSyncDirective = extend({}, origAsyncDirective, { - controller: null, templateUrl: null, transclude: null, scope: null + templateUrl: null, transclude: null, scope: null }); $compileNode.html(''); |
