Class Binding in Angular 8 Last Updated : 23 Sep, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report Class binding in Angular makes it very easy to set the class property of a view element. We can set or remove the CSS class names from an element's class attribute with the help of class binding. We bind a class of a DOM element to a field that is a defined property in our Typescript Code. Its syntax is like that of property binding. Syntax: <element [class] = "typescript_property"> Approach: Define a property element in the app.component.ts file.In the app.component.html file, set the class of the HTML element by assigning the property value to the app.component.ts file’s element.Example 1: Setting the class element using class binding. app.component.html HTML <h1 [class] = "geeky"> GeeksforGeeks </h1> Upper Heading's class is : "{{ g[0].className }}" app.component.ts JavaScript import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html' }) export class AppComponent { geeky = "GeekClass"; g = document.getElementsByClassName(this.geeky); } Output: Example 2: setting the class element using a function. app.component.html HTML <h1 [class] = "setClass()"> GeeksforGeeks </h1> Upper Heading's class is : "{{ g[0].className }}" app.component.ts JavaScript import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html' }) export class AppComponent { setClass() { return "GeeksforGeeks"; } g = document.getElementsByClassName(this.setClass()); } Output: Comment More infoAdvertise with us Next Article Event Binding in Angular 8 T taran910 Follow Improve Article Tags : Web Technologies AngularJS AngularJS-Misc Similar Reads Event Binding in Angular 8 In Angular 8, event binding is used to handle the events raised by the user actions like button click, mouse movement, keystrokes, etc. When the DOM event happens at an element(e.g. click, keydown, keyup), it calls the specified method in the particular component. Using Event Binding we can bind da 2 min read 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: Create the angular app to be usedIn app.component.html make an element and sets i 1 min read Style Binding in Angular 17 In Angular, creating visually appealing and dynamic user interfaces is important for delivering an engaging user experience. One such powerful feature is Style Binding. It allows you to dynamically apply CSS styles to HTML elements based on component data or expressions. In this article, we'll explo 2 min read Binding Syntax In Angular In Angular, binding syntax lets you determine the channel of data transmission between the component class and the template. Among various types of bindings supported by Angular are interpolation, property binding, event binding, and two-way-data-binding. Therefore, it is important to understand var 3 min read Angular 8 | Introduction Angular 8 is a client-side TypeScript based, front-end web framework by Google. Angular 8 is a great, reusable UI (User Interface) library for the developers which help in building attractive, steady, and utilitarian web pages and web application. Angular 8 is a ground-breaking JavaScript framework 4 min read Components in Angular 8 The component is the basic building block of Angular. It has a selector, template, style, and other properties, and it specifies the metadata required to process the component. Creating a Component in Angular 8: To create a component in any angular application, follow the below steps: Get to the ang 2 min read Like