NgClass Directive

    We can bind a string directly to the attribute. This works just like adding an html class attribute.

    View Example

    Here, since we are binding to the ngClass directive by using an expression, we need to wrap the directive name in square brackets. Passing in an array is useful when you want to have a function put together the list of applicable class names.

    View Example

    Here we can see that since the object's and flat properties are true, those classes are applied but since dark is false, it's not applied.