pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://angular.dev/api/common/NgClass

(theme === 'auto' && prefersDark)) { documentClassList.add(DARK_MODE_CLASS_NAME); } else { documentClassList.add(LIGHT_MODE_CLASS_NAME); } if (location.search.includes('uwu')) { documentClassList.add('uwu'); } NgClass • Angular
    • Overview
@angular/common

NgClass

directive
stable

Adds and removes CSS classes on an HTML element.

API

    
      class NgClass implements DoCheck {}
    
    

constructor

NgClass
@param_ngElElementRef<any>
@param_rendererRenderer2
@returnsNgClass

klass

string

ngClass

string | string[] | Set<string> | { [klass: string]: any; } | null | undefined

ngDoCheck

void
@returnsvoid

Description

Adds and removes CSS classes on an HTML element.

The CSS classes are updated as follows, depending on the type of the expression evaluation:

  • string - the CSS classes listed in the string (space delimited) are added,
  • Array - the CSS classes declared as Array elements are added,
  • Object - keys are CSS classes that get added when the expression given in the value evaluates to a truthy value, otherwise they are removed.

Exported by

Usage Notes

<some-element [ngClass]="stringExp|arrayExp|objExp|Set">...</some-element>

<some-element [ngClass]="{'class1 class2 class3' : true}">...</some-element>

For more simple use cases you can use the class bindings directly. It doesn't require importing a directive.

<some-element [class]="'first second'">...</some-element>

<some-element [class.expanded]="isExpanded">...</some-element>

<some-element [class]="['first', 'second']">...</some-element>

<some-element [class]="{'first': true, 'second': true, 'third': false}">...</some-element>
Jump to details
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy