4

I have this component template:

<div id="one" (click)=""></div>
<div id="two" #two></div>

What should I put inside (click)="" to assign the second div some class. I know it can be done inside component code, but is there a way to do it directly in template?

manidos
  • 3,244
  • 4
  • 29
  • 65

2 Answers2

4
(click)="two.className = 'someClass'"

or

(click)="two.classList.add('someClass')"

See also Change an element's class with JavaScript

Community
  • 1
  • 1
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
-1
<div id="one" (click)="document.getElementById('#two').classList.add('soemClass')"></div>
<div id="two" #two></div>

This may help you!

Yogesh Aggarwal
  • 1,071
  • 2
  • 12
  • 30