diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/widgets.js | 59 |
1 files changed, 19 insertions, 40 deletions
diff --git a/src/widgets.js b/src/widgets.js index 861e61bf..c89f4179 100644 --- a/src/widgets.js +++ b/src/widgets.js @@ -112,18 +112,6 @@ angularWidget('ng:include', function(element){ useScope = scope.$eval(scopeExp), fromCache; - function updateContent(content) { - element.html(content); - if (useScope) { - childScope = useScope; - } else { - releaseScopes.push(childScope = scope.$new()); - } - compiler.compile(element)(childScope); - $autoScroll(); - scope.$eval(onloadExp); - } - function clearContent() { childScope = null; element.html(''); @@ -133,16 +121,17 @@ angularWidget('ng:include', function(element){ releaseScopes.pop().$destroy(); } if (src) { - if ((fromCache = $templateCache.get(src))) { - scope.$evalAsync(function() { - updateContent(fromCache); - }); - } else { - $http.get(src).on('success', function(response) { - updateContent(response); - $templateCache.put(src, response); - }).on('error', clearContent); - } + $http.get(src, {cache: $templateCache}).on('success', function(response) { + element.html(response); + if (useScope) { + childScope = useScope; + } else { + releaseScopes.push(childScope = scope.$new()); + } + compiler.compile(element)(childScope); + $autoScroll(); + scope.$eval(onloadExp); + }).on('error', clearContent); } else { clearContent(); } @@ -586,30 +575,20 @@ angularWidget('ng:view', function(element) { var template = $route.current && $route.current.template, fromCache; - function updateContent(content) { - element.html(content); - compiler.compile(element)($route.current.scope); - } - function clearContent() { element.html(''); } if (template) { - if ((fromCache = $templateCache.get(template))) { - scope.$evalAsync(function() { - updateContent(fromCache); - }); - } else { - // xhr's callback must be async, see commit history for more info - $http.get(template).on('success', function(response) { - // ignore callback if another route change occured since - if (newChangeCounter == changeCounter) - updateContent(response); - $templateCache.put(template, response); + // xhr's callback must be async, see commit history for more info + $http.get(template, {cache: $templateCache}).on('success', function(response) { + // ignore callback if another route change occured since + if (newChangeCounter == changeCounter) { + element.html(response); + compiler.compile(element)($route.current.scope); $autoScroll(); - }).on('error', clearContent); - } + } + }).on('error', clearContent); } else { clearContent(); } |
