Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix($compile): reference local in isolate scope #1359

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ng/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ function $CompileProvider($provide) {
lastValue = scope[scopeName] = parentValue;
} else {
// if the parent can be assigned then do so
parentSet(parentScope, lastValue = scope[scopeName]);
parentSet(parentScope, parentValue = lastValue = scope[scopeName]);
}
}
return parentValue;
Expand Down
19 changes: 19 additions & 0 deletions test/ng/compileSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1709,6 +1709,7 @@ describe('$compile', function() {
attrAlias: '@attr',
ref: '=',
refAlias: '= ref',
reference: '=',
expr: '&',
exprAlias: '&expr'
},
Expand Down Expand Up @@ -1830,6 +1831,24 @@ describe('$compile', function() {
$rootScope.$apply();
expect(componentScope.ref).toBe('hello misko');
}));

// regression
it('should stabilize model', inject(function() {
compile('<div><span my-component reference="name">');

var lastRefValueInParent;
$rootScope.$watch('name', function(ref) {
lastRefValueInParent = ref;
});

$rootScope.name = 'aaa';
$rootScope.$apply();

componentScope.reference = 'new';
$rootScope.$apply();

expect(lastRefValueInParent).toBe('new');
}));
});


Expand Down