【发布时间】:2017-01-04 20:02:30
【问题描述】:
这是我的模板
<div class="navbarTitle" [@myTrigger]='state' (mouseenter)='animateUnderscore()'>Hello<span class="titleUnderscore">_</span>Everyone</div>
如您所见,div 中有一个 span 元素,其中包含 Hello 和 Everyone 文本之间的下划线。
我的组件中切换文本颜色的方法(动画是使用组件装饰器中定义的角度动画完成的)
//** Within component
titleIsBlue: boolean = false;
//method which changes the color of the underscore on hover
animateUnderscore = () => {
if (this.titleIsBlue) {
state = 'black';
titleIsBlue = false;
} else {
titleIsBlue = true;
state = 'blue';
}
}
//** Within Component
如何获取包含下划线的span 元素,以便更改它的颜色?
我不想使用 jQuery 或 Angular2 的 elementRef。
【问题讨论】:
标签: angular angular2-animation