Questions tagged [angularjs-ng-class-even]

The ngClassOdd and ngClassEven directives work exactly as ngClass, except they work in conjunction with ngRepeat and take effect only on odd (even) rows.

The directive operates in three different ways, depending on which of three types the expression evaluates to:

  1. If the expression evaluates to a string, the string should be one or more space-delimited class names.

  2. If the expression evaluates to an object, then for each key-value pair of the object with a truthy value the corresponding key is used as a class name.

  3. If the expression evaluates to an array, each element of the array should either be a string as in type 1 or an object as in type 2. This means that you can mix strings and objects together in an array to give you more control over what CSS classes appear. See the code below for an example of this.

The directive won't add duplicate classes if a particular class was already set.

When the expression changes, the previously added classes are removed and only then are the new classes added.

Usage

as attribute:

<ANY
  ng-class="expression">
...
</ANY>

as CSS class:

<ANY class="ng-class: expression;"> ... </ANY>
4 questions
10
votes
3 answers

Implementing ngClassEven ngClassOdd for angular 2

I tried to implement ng-class-even and ng-class-odd ( from angular 1) type behaviour in angular 2 application. I have written the code below and its working fine, I want to know if there is any other way of doing this. HTML
5
votes
3 answers

ngClassOdd/ngClassEven not working as expected

Using Angular version 1.2.15, I found a bug that it seems started on version 1.2.2 until 1.2.15. Plunker Demo to reproduce Html
  1. Dalorzo
    • 19,834
    • 7
    • 55
    • 102
1
vote
3 answers

Why ng-class-even required extra quotes

I am working on angularJS where my codes are fine but i am stuck at one place where i cant find why extra quotes are required in ng-class-even directive. In this line why striped is written…
Gaurav Aggarwal
  • 9,809
  • 6
  • 36
  • 74
1
vote
1 answer

Angular nested ng-repeat class variable

So I have a fairly complex angular table, and I have the repeating portion all good to go, but when I set a variable with ng-class-even and ng-class-odd, the variable doesn't seem to persist. Maybe I'm misunderstanding the scope of the ng-repeat,…