diff --git a/src/ng/directive/ngSwitch.js b/src/ng/directive/ngSwitch.js index f5d824a881dc..4c11f62f0421 100644 --- a/src/ng/directive/ngSwitch.js +++ b/src/ng/directive/ngSwitch.js @@ -144,6 +144,10 @@ var ngSwitchDirective = ['$animate', function($animate) { previousLeaveAnimations = [], selectedScopes = []; + var spliceFactory = function(array, index) { + return function() { array.splice(index, 1); }; + }; + scope.$watch(watchExpr, function ngSwitchWatchAction(value) { var i, ii; for (i = 0, ii = previousLeaveAnimations.length; i < ii; ++i) { @@ -154,11 +158,8 @@ var ngSwitchDirective = ['$animate', function($animate) { for (i = 0, ii = selectedScopes.length; i < ii; ++i) { var selected = getBlockNodes(selectedElements[i].clone); selectedScopes[i].$destroy(); - var promise = previousLeaveAnimations[i] = $animate.leave(selected); - promise.then(function() { - previousLeaveAnimations.splice(i, 1); - }); + promise.then(spliceFactory(previousLeaveAnimations, i)); } selectedElements.length = 0;