aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ng/compile.js2
-rw-r--r--test/ng/compileSpec.js19
2 files changed, 20 insertions, 1 deletions
diff --git a/src/ng/compile.js b/src/ng/compile.js
index ccdd1880..3fa4691c 100644
--- a/src/ng/compile.js
+++ b/src/ng/compile.js
@@ -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;
diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js
index 3d6144ac..b5e4c450 100644
--- a/test/ng/compileSpec.js
+++ b/test/ng/compileSpec.js
@@ -1709,6 +1709,7 @@ describe('$compile', function() {
attrAlias: '@attr',
ref: '=',
refAlias: '= ref',
+ reference: '=',
expr: '&',
exprAlias: '&expr'
},
@@ -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');
+ }));
});