比方说,我有两个点0到300,背景颜色是红色。
现在,我想画0到75绿色,75到150黄色。我有这些和两个点,可以从Typescript视图模型类中给出值。
<div style="background-color: red">
<div style="background-color: green">
</div>
<div style="background-color: yellow">
</div>
</div>我的场景非常复杂,有6-7种不同的颜色。我的方法是正确的,还是有更好的方法?我的应用程序是TypeScript和Angular 2。
发布于 2017-05-26 03:26:39
使用ngStyle或ngStyle。背景颜色
<div [ngStyle]="randomcss()">
<div [ngStyle]="randomcss()">
</div>
</div>组件
export class AppComponent {
randomcss(){
// based on your points return color
return {'background-color':'red'}
}
}https://stackoverflow.com/questions/44188075
复制相似问题