Open In App

What is NgClass in Angular 10 ?

In this article, we are going to see what is NgClass in Angular 10 and how to use it.

NgClass is used to Add or remove CSS classes on an HTML element



Syntax:

<element [ngClass] = "typescript_property">

Approach: 



Example 1:




import { Component, OnInit } from '@angular/core';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html'
})
export class AppComponent {
  
  }




<div [ngClass] ="'gfgclass'">
  GeeksforGeeks
</div>

Output:

Article Tags :