How to add class to a div when hovered on the div.
Template -
<div class="red">On hover add class ".yellow"</div>
Component -
import {Component} from 'angular2/core';
@Component({
selector: 'hello-world',
templateUrl: 'src/hello_world.html',
styles: [`
.red {
background: red;
}
.yellow {
background: yellow;
}
`]
})
export class HelloWorld {
}
Demo
[ NOTE - I specifically want to add a new class and not modify the existing classes ]
Sigh! It is such a normal use case and I do not see any straight forward solution yet!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…