diff options
| author | Igor Minar | 2011-11-24 03:53:04 -0800 |
|---|---|---|
| committer | Igor Minar | 2011-11-30 14:49:35 -0500 |
| commit | dbd880cc0a9521bd5b9c96ca3f052450c3def336 (patch) | |
| tree | fc524b84aab7ea1f67ff14962ea31f1e735f628c /src/widgets.js | |
| parent | bf8e0540f8195edbaaa3d0138bd6a26e79e1ab58 (diff) | |
| download | angular.js-dbd880cc0a9521bd5b9c96ca3f052450c3def336.tar.bz2 | |
feat($http): add promise support
quite messy, some tests are missing, contains an experimental jasmine DI support)
Diffstat (limited to 'src/widgets.js')
| -rw-r--r-- | src/widgets.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/widgets.js b/src/widgets.js index c89f4179..618de04d 100644 --- a/src/widgets.js +++ b/src/widgets.js @@ -109,8 +109,7 @@ angularWidget('ng:include', function(element){ }); this.$watch(function() {return changeCounter;}, function(scope) { var src = scope.$eval(srcExp), - useScope = scope.$eval(scopeExp), - fromCache; + useScope = scope.$eval(scopeExp); function clearContent() { childScope = null; @@ -121,7 +120,7 @@ angularWidget('ng:include', function(element){ releaseScopes.pop().$destroy(); } if (src) { - $http.get(src, {cache: $templateCache}).on('success', function(response) { + $http.get(src, {cache: $templateCache}).success(function(response) { element.html(response); if (useScope) { childScope = useScope; @@ -131,7 +130,7 @@ angularWidget('ng:include', function(element){ compiler.compile(element)(childScope); $autoScroll(); scope.$eval(onloadExp); - }).on('error', clearContent); + }).error(clearContent); } else { clearContent(); } @@ -572,23 +571,21 @@ angularWidget('ng:view', function(element) { }); this.$watch(function() {return changeCounter;}, function(scope, newChangeCounter) { - var template = $route.current && $route.current.template, - fromCache; + var template = $route.current && $route.current.template; function clearContent() { element.html(''); } if (template) { - // xhr's callback must be async, see commit history for more info - $http.get(template, {cache: $templateCache}).on('success', function(response) { + $http.get(template, {cache: $templateCache}).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); + }).error(clearContent); } else { clearContent(); } |
