diff --git a/src/directives.js b/src/directives.js
index 9aa0d57eb557..64a06359affb 100644
--- a/src/directives.js
+++ b/src/directives.js
@@ -571,9 +571,14 @@ function ngClass(selector) {
var existing = element[0].className + ' ';
return function(element){
this.$onEval(function(){
- if (selector(this.$index)) {
- var value = this.$eval(expression);
+ var scope = this;
+
+ 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);
}
}, element);
diff --git a/test/directivesSpec.js b/test/directivesSpec.js
index 22d3c84bb843..afb4e04fe71b 100644
--- a/test/directivesSpec.js
+++ b/test/directivesSpec.js
@@ -220,6 +220,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('
' +
+ '' +
+ '');
+ scope.$eval();
+ var e1 = jqLite(element[0].childNodes[1]);
+ var e2 = jqLite(element[0].childNodes[2]);
+
+ expect(e1.hasClass('plainClass')).toBeTruthy();
+ expect(e1.hasClass('odd')).toBeTruthy();
+ expect(e1.hasClass('even')).toBeFalsy();
+ expect(e2.hasClass('plainClass')).toBeTruthy();
+ expect(e2.hasClass('even')).toBeTruthy();
+ expect(e2.hasClass('odd')).toBeFalsy();
+ });
+
+
+ it('should allow both ng:class and ng:class-odd/even with multiple classes', function() {
+ var scope = compile('' +
+ '' +
+ '');
+ scope.$eval();
+ var e1 = jqLite(element[0].childNodes[1]);
+ var e2 = jqLite(element[0].childNodes[2]);
+
+ expect(e1.hasClass('A')).toBeTruthy();
+ expect(e1.hasClass('B')).toBeTruthy();
+ expect(e1.hasClass('C')).toBeTruthy();
+ expect(e1.hasClass('D')).toBeTruthy();
+ expect(e1.hasClass('E')).toBeFalsy();
+ expect(e1.hasClass('F')).toBeFalsy();
+
+ expect(e2.hasClass('A')).toBeTruthy();
+ expect(e2.hasClass('B')).toBeTruthy();
+ expect(e2.hasClass('E')).toBeTruthy();
+ expect(e2.hasClass('F')).toBeTruthy();
+ expect(e2.hasClass('C')).toBeFalsy();
+ expect(e2.hasClass('D')).toBeFalsy();
+ });
+
+
describe('ng:style', function(){
it('should set', function(){
var scope = compile('');