diff --git a/src/directives.js b/src/directives.js index 4712f250c097..0659f13679e5 100644 --- a/src/directives.js +++ b/src/directives.js @@ -596,8 +596,11 @@ function ngClass(selector) { return function(element) { this.$observe(function(scope) { if (selector(scope.$index)) { + var ngClassVal = scope.$eval(element.attr('ng:class')); + if (isArray(ngClassVal)) ngClassVal = ngClassVal.join(' '); var value = scope.$eval(expression); if (isArray(value)) value = value.join(' '); + if (ngClassVal && ngClassVal !== value) value = value + ' ' + ngClassVal; element[0].className = trim(existing + value); } }); diff --git a/test/directivesSpec.js b/test/directivesSpec.js index a05861ae9f4f..0ea420fb7b1d 100644 --- a/test/directivesSpec.js +++ b/test/directivesSpec.js @@ -225,6 +225,50 @@ describe("directive", function(){ expect(e2.hasClass('even')).toBeTruthy(); }); + + it('should allow both ng:class and ng:class-odd/even on the same element', function() { + var scope = compile('