Check out example codes for "ngclass angular". It will help you in understanding the concepts better.

Code Example 1

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

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

<some-element [ngClass]="{'first': true, 'second': true, 'third': false}">...</some-element>

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

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

Code Example 2

ngDoCheck()

Code Example 3

[ngClass]="(step=='step1')?'my-class1':'my-class2'"

Code Example 4

[ngClass]="{1:'my-class1',2:'my-class2',3:'my-class4'}[step]"

Code Example 5

[ngClass]="{'my-class': step=='step1', 'my-class2':step=='step2' }"

Code Example 6

<div [ngClass]="{ 
'green': number > 5,
  'red': number <= 5,
}" ></div>
//if the number is over 5, the class 'green' will be added to the div.
//if the number is below or equal 5, the class 'red' will be added to the div.

Learn ReactJs, React Native from akashmittal.com