# `ngClass` (directive in module `ng` )

Improve this doc

## Description

The `ngClass` allows you to set CSS class on HTML element dynamically by databinding an expression that represents all classes to be added.

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 the new classes are added.

## Usage

as attribute

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

as class

    <ANY class="ng-class: {expression};">
       ...
    </ANY>

### Parameters

- `ngClass – {expression} –`

  Expression to eval. The result of the evaluation can be a string representing space delimited class names, an array, or a map of class names to boolean values.

## Example

#### Source

#### Demo