diff options
| author | Matias Niemelä | 2013-08-02 17:51:43 -0400 |
|---|---|---|
| committer | Misko Hevery | 2013-08-09 14:39:57 -0700 |
| commit | 1b5bee4fa12b1f14e117f7ca222c2e2b64cc8558 (patch) | |
| tree | 57654eb39ebd714b4d8d4b6570f0227bfaa5660b /src | |
| parent | 45dc9ee7b4a1e004f9fb7edde41d4805d1402ffa (diff) | |
| download | angular.js-1b5bee4fa12b1f14e117f7ca222c2e2b64cc8558.tar.bz2 | |
fix(ngInclude): ensure ngInclude is terminal and uses its own manual transclusion system
Diffstat (limited to 'src')
| -rw-r--r-- | src/ng/directive/ngInclude.js | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/src/ng/directive/ngInclude.js b/src/ng/directive/ngInclude.js index 0f1f245c..e4484e81 100644 --- a/src/ng/directive/ngInclude.js +++ b/src/ng/directive/ngInclude.js @@ -149,18 +149,23 @@ * @description * Emitted every time the ngInclude content is reloaded. */ +var NG_INCLUDE_PRIORITY = 500; var ngIncludeDirective = ['$http', '$templateCache', '$anchorScroll', '$compile', '$animate', '$sce', function($http, $templateCache, $anchorScroll, $compile, $animate, $sce) { return { restrict: 'ECA', terminal: true, - transclude: 'element', - compile: function(element, attr, transclusion) { + priority: NG_INCLUDE_PRIORITY, + compile: function(element, attr) { var srcExp = attr.ngInclude || attr.src, onloadExp = attr.onload || '', autoScrollExp = attr.autoscroll; - return function(scope, $element) { + element.html(''); + var anchor = jqLite(document.createComment(' ngInclude: ' + srcExp + ' ')); + element.replaceWith(anchor); + + return function(scope) { var changeCounter = 0, currentScope, currentElement; @@ -184,23 +189,21 @@ var ngIncludeDirective = ['$http', '$templateCache', '$anchorScroll', '$compile' if (thisChangeId !== changeCounter) return; var newScope = scope.$new(); - transclusion(newScope, function(clone) { - cleanupLastIncludeContent(); + cleanupLastIncludeContent(); - currentScope = newScope; - currentElement = clone; + currentScope = newScope; + currentElement = element.clone(); + currentElement.html(response); + $animate.enter(currentElement, null, anchor); - currentElement.html(response); - $animate.enter(currentElement, null, $element); - $compile(currentElement.contents())(currentScope); + $compile(currentElement, false, NG_INCLUDE_PRIORITY - 1)(currentScope); - if (isDefined(autoScrollExp) && (!autoScrollExp || scope.$eval(autoScrollExp))) { - $anchorScroll(); - } + if (isDefined(autoScrollExp) && (!autoScrollExp || scope.$eval(autoScrollExp))) { + $anchorScroll(); + } - currentScope.$emit('$includeContentLoaded'); - scope.$eval(onloadExp); - }); + currentScope.$emit('$includeContentLoaded'); + scope.$eval(onloadExp); }).error(function() { if (thisChangeId === changeCounter) cleanupLastIncludeContent(); }); |
