diff --git a/src/ng/compile.js b/src/ng/compile.js index 99d778e0de23..cff8fb38516c 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -1697,7 +1697,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { case '@': attrs.$observe(attrName, function(value) { - isolateScope[scopeName] = value; + isolateBindingContext[scopeName] = value; }); attrs.$$observers[attrName].$$scope = scope; if( attrs[attrName] ) { diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index 3412491c543c..2a0d84d04150 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -3567,6 +3567,32 @@ describe('$compile', function() { }); + it('should update @-bindings on controller when bindToController and attribute change observed', function(){ + module(function($compileProvider) { + $compileProvider.directive('atBinding', valueFn({ + template: '
{{At.text}}
', + scope: { + text: '@atBinding' + }, + controller: function($scope) {}, + bindToController: true, + controllerAs: 'At' + })); + }); + + inject(function($compile, $rootScope) { + element = $compile('')($rootScope); + var p = element.find('p'); + $rootScope.$digest(); + expect(p.text()).toBe('Test: '); + + $rootScope.text = 'Kittens'; + $rootScope.$digest(); + expect(p.text()).toBe('Test: Kittens'); + }); + }); + + it('should expose isolate scope variables on controller with controllerAs when bindToController is true', function() { var controllerCalled = false; module(function($compileProvider) {