Is there a way to add a class from the .ts file, using Angular solutions
I want to d
Use Renderer
See here:https://angular.io/api/core/Renderer
and here:https://angular.io/api/core/Renderer#setElementClass
import { Renderer } from '@angular/core';
constructor(private render:Renderer) { }
ChangeScreen(event:any) {
this.renderer.setElementClass(event.target,"selected",true);
}
In html:
Or Render2
:
See here:https://angular.io/api/core/Renderer2
and here:https://angular.io/api/core/Renderer2#addClass
import { Renderer2 } from '@angular/core';
constructor(private render:Renderer2) { }
ChangeScreen(event:any) {
this.renderer.addClass(event.target,"selected");
}
In html: