Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 21dac2a

Browse files
bradw2ktbosch
authored andcommitted
docs(ngClass): Explain all 3 ways how to use ngClass
Closes #6324.
1 parent 481508d commit 21dac2a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/ng/directive/ngClass.js

+12
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,18 @@ function classDirective(name, selector) {
7171
* The `ngClass` directive allows you to dynamically set CSS classes on an HTML element by databinding
7272
* an expression that represents all classes to be added.
7373
*
74+
* The directive operates in three different ways, depending on which of three types the expression
75+
* evaluates to:
76+
*
77+
* 1. If the expression evaluates to a string, the string should be one or more space-delimited class
78+
* names.
79+
*
80+
* 2. If the expression evaluates to an array, each element of the array should be a string that is
81+
* one or more space-delimited class names.
82+
*
83+
* 3. If the expression evaluates to an object, then for each key-value pair of the
84+
* object with a truthy value the corresponding key is used as a class name.
85+
*
7486
* The directive won't add duplicate classes if a particular class was already set.
7587
*
7688
* When the expression changes, the previously added classes are removed and only then the

0 commit comments

Comments
 (0)