What is NgClass in Angular 10 ?
Last Updated :
30 Apr, 2021
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:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...