改变当前元素的样式,Angular

问题描述:

如何改变当前元素的样式在里面?改变当前元素的样式,Angular

<template #weekEvents let-displayEvent="displayEvent"> 
     <div class="calendar-event-inner">{{displayEvent.event.title}}</div> 
    </template> 

我需要更改模板的颜色,但它得到了初始化后,才因为迭代去和颜色必须被动态分配。有没有办法做到这一点?

+0

使用'id'与模板的属性,并覆盖其颜色。 –

+1

“模板”是否被弃用的角度指令?如果是,则无法对其进行设计,因为这是一个不会呈现的结构指令。但是你可以#calendar-event-inner。什么是变量,风格应该取决于什么? –

如果你想改变任何单一模板的颜色,那么你可以使用id属性,如下图所示:

HTML:

 <simple-element id="test">simple content</simple-element> 

CSS:

#asd 
{ 
    color: red; 
} 

如果您想要应用多种颜色但您必须使用一种模板class属性,下面的屁股:

HTML:

 <div products-information class="custonColor">Product information</div> 

    <products-information class="custonColor">some product Information</products-information> 

CSS:

.custonColor 
{ 
    color: green; 
} 

Complete Working Demo