diff --git a/src/ng/directive/ngRepeat.js b/src/ng/directive/ngRepeat.js index 7298375b..c89bcdd2 100644 --- a/src/ng/directive/ngRepeat.js +++ b/src/ng/directive/ngRepeat.js @@ -360,6 +360,7 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) { $animate.move(getBlockElements(block.clone), null, jqLite(previousNode)); } previousNode = getBlockEnd(block); + updateScope(block.scope, index); } else { // new item which we don't know about $transclude(function(clone, scope) { @@ -372,9 +373,9 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) { // by a directive with templateUrl when it's template arrives. block.clone = clone; nextBlockMap[block.id] = block; + updateScope(block.scope, index); }); } - updateScope(block.scope, index); } lastBlockMap = nextBlockMap; }); diff --git a/test/ng/directive/ngRepeatSpec.js b/test/ng/directive/ngRepeatSpec.js index fd8f216a..9be6ec66 100644 --- a/test/ng/directive/ngRepeatSpec.js +++ b/test/ng/directive/ngRepeatSpec.js @@ -1195,6 +1195,21 @@ describe('ngRepeat and transcludes', function() { }); }); + + it('should set the state before linking', function() { + module(function($compileProvider) { + $compileProvider.directive('assertA', valueFn(function(scope) { + // This linking function asserts that a is set. + // If we only test this by asserting binding, it will work even if the value is set later. + expect(scope.a).toBeDefined(); + })); + }); + inject(function($compile, $rootScope) { + var element = $compile('