How to add | remove css class in angular element?

Sergii

How to add | remove css class in angular element?

Access to angular element is via: this.elementRef.nativeElement (import { ElementRef } from '@angular/core';). CSS class name is myclass.

Subtain Ishfaq
constructor(public elementRef: ElementRef, private renderer: Renderer)
{
        this.renderer.setElementClass(this.elementRef, 'class');
   // or 

            this.elementRef.nativeElement.classList.add('class');

}
  1. Using Renderer
  2. Using addClass on Native element

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to add/remove a class to the parent element of a checkbox on change in Angular js

From Dev

Add and remove class when element clicked with Angular

From Dev

How to add a class to an element with CSS

From Dev

how to add a class to one a element and remove a class from all siblings a elements angular

From Dev

how to add and remove css class in javascript function

From Dev

How to add CSS class dynamically to html element

From Dev

Adblock. Add css class or remove attribute from element

From Dev

How to add a class to an element when another element gets a class in angular?

From Dev

Angular 2+ Add or Remove a Class of an element that belongs to another component

From Dev

How to add css class to an element inside nav element

From Dev

How to add a class to an element and remove to the others siblings in AngularJS

From Dev

How to remove a class in a list of elements and add to another element Jquery?

From Dev

how can I add and remove class of a element whenever it is clicked

From Dev

How can I add and remove an active class to an element in pure JavaScript

From Dev

How to add/remove class of child element on click of var ID?

From Dev

how can I add and remove class of a element whenever it is clicked

From Dev

How to add and remove a class if another element is clicked in AngularJS?

From Dev

How to add a class to an element and remove to the others siblings in AngularJS

From Dev

Jquery remove/add CSS class

From Dev

remove class and add class on single element

From Dev

remove class and add class when an element is clicked

From Dev

css add class to selected element

From Java

Thymeleaf: how to use conditionals to dynamically add/remove a CSS class

From Dev

How do I add and remove CSS class on keyup in a textarea?

From Dev

angular add class to span element

From Dev

How to add and remove active class on click - angular way

From Dev

How to add/remove class to the clicked parent link in Angular JS?

From Dev

How to add or remove a bootstrap "active" class in Angular 4, Typescript 2

From Dev

How to add class CSS after ng-click to parent element?

Related Related

  1. 1

    How to add/remove a class to the parent element of a checkbox on change in Angular js

  2. 2

    Add and remove class when element clicked with Angular

  3. 3

    How to add a class to an element with CSS

  4. 4

    how to add a class to one a element and remove a class from all siblings a elements angular

  5. 5

    how to add and remove css class in javascript function

  6. 6

    How to add CSS class dynamically to html element

  7. 7

    Adblock. Add css class or remove attribute from element

  8. 8

    How to add a class to an element when another element gets a class in angular?

  9. 9

    Angular 2+ Add or Remove a Class of an element that belongs to another component

  10. 10

    How to add css class to an element inside nav element

  11. 11

    How to add a class to an element and remove to the others siblings in AngularJS

  12. 12

    How to remove a class in a list of elements and add to another element Jquery?

  13. 13

    how can I add and remove class of a element whenever it is clicked

  14. 14

    How can I add and remove an active class to an element in pure JavaScript

  15. 15

    How to add/remove class of child element on click of var ID?

  16. 16

    how can I add and remove class of a element whenever it is clicked

  17. 17

    How to add and remove a class if another element is clicked in AngularJS?

  18. 18

    How to add a class to an element and remove to the others siblings in AngularJS

  19. 19

    Jquery remove/add CSS class

  20. 20

    remove class and add class on single element

  21. 21

    remove class and add class when an element is clicked

  22. 22

    css add class to selected element

  23. 23

    Thymeleaf: how to use conditionals to dynamically add/remove a CSS class

  24. 24

    How do I add and remove CSS class on keyup in a textarea?

  25. 25

    angular add class to span element

  26. 26

    How to add and remove active class on click - angular way

  27. 27

    How to add/remove class to the clicked parent link in Angular JS?

  28. 28

    How to add or remove a bootstrap "active" class in Angular 4, Typescript 2

  29. 29

    How to add class CSS after ng-click to parent element?

HotTag

Archive