Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

What is NgClass in Angular 10 ?

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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: 

  • Create the angular app to be used
  • In app.component.html make an element and sets its class using ngclass directive
  • serve the angular app using ng serve to see the output

Example 1:

app.component.ts




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


app.component.html




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


Output:

My Personal Notes arrow_drop_up
Last Updated : 30 Apr, 2021
Like Article
Save Article
Similar Reads
Related Tutorials