diff --git a/src/ng/compile.js b/src/ng/compile.js index 122554a0c443..db9a0f4f075a 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -2969,10 +2969,15 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { } }); attrs.$$observers[attrName].$$scope = scope; - if (isString(attrs[attrName])) { + lastValue = attrs[attrName]; + if (isString(lastValue)) { // If the attribute has been provided then we trigger an interpolation to ensure // the value is there for use in the link fn - destination[scopeName] = $interpolate(attrs[attrName])(scope); + destination[scopeName] = $interpolate(lastValue)(scope); + } else if (isBoolean(lastValue)) { + // If the attributes is one of the BOOLEAN_ATTR then Angular will have converted + // the value to boolean rather than a string, so we special case this situation + destination[scopeName] = lastValue; } break; diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index f885d3106433..534cd352b941 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -2694,6 +2694,24 @@ describe('$compile', function() { expect(element.isolateScope()['watch']).toBe('watch'); }) ); + + it('should handle @ bindings on BOOLEAN attributes', function() { + var checkedVal; + module(function($compileProvider) { + $compileProvider.directive('test', function() { + return { + scope: { checked: '@' }, + link: function(scope, element, attrs) { + checkedVal = scope.checked; + } + }; + }); + }); + inject(function($compile, $rootScope) { + $compile('')($rootScope); + expect(checkedVal).toEqual(true); + }); + }); });