首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不同状态角6的图标颜色

不同状态角6的图标颜色
EN

Stack Overflow用户
提问于 2019-02-18 05:30:32
回答 1查看 3.3K关注 0票数 1

我对角度的看法是这样的:

这是我的dashboard.component.ts

代码语言:javascript
复制
export class DashboardComponent implements OnInit {
  tablePresetColumns;
  tablePresetData;
 ngOnInit() {
  this.tablePresetColumns = [{id: 1,content: 'Username'},{id: 2,content: 'Status'}];
  this.tablePresetData = [[{id: 1,content: 'john.doe@random.com'},{id: 2,content: 'Busy'}],[{id: 1,content: 'test2@random.com'},{id: 2,content: 'overload'}]];
 }
} 

这就是我在dashboard.component上调用表的方式:

代码语言:javascript
复制
<div eds-tile class="xl-4" style="height: 700px">
<eds-tile-title>User on Shift</eds-tile-title>  
<eds-table [columns]="tablePresetColumns" [data]="tablePresetData" [modes]="['compact', 'dashed']"></eds-table>
</div>

我的编辑桌:

代码语言:javascript
复制
selector: 'eds-table',
template: "<table class=\"table\" [ngClass]=\"modes\">\n  <thead *ngIf=\"columns\">\n    <tr>\n      <th *ngFor=\"let col of columns\">\n        {{col.content}}\n      </th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr *ngFor=\"let row of data\">\n      <td *ngFor=\"let cell of row\">\n        {{cell.content}}\n      </td>\n    </tr>\n  </tbody>\n</table>\n",

我的问题是,我应该怎么做才能使我的观点至少变成这样,我的意思是,当状态很忙的时候,

图标颜色是绿色的,或者是黄色的,超载是红色的(在文本的右边):

需要支援的人,谢谢..。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-02-18 05:37:03

您可以在<td>使用下面的内容

代码语言:javascript
复制
<td *ngFor="let cell of row" 
  [ngStyle]="{'color': (cell.content === 'Busy') ? 'green' : (cell.content === 'overload') ? 'red' : (cell.content === 'idle') ? 'yellow' : ''}">{{cell.content}}
</td>

用下面的方式,

代码语言:javascript
复制
<td [ngClass]="{
                'busy' : cell.content == 'Busy',
                'idle' : cell.content == 'Idle'
                'overload' : cell.content == 'Overload'
             }" *ngFor="let cell of row"> {{cell.content}} </td>

在你的css中

代码语言:javascript
复制
.busy {
    color: green;
}

.idle {
    color: yellow;
}

.overload {
    color: red;
}

更新答复

代码语言:javascript
复制
   <td *ngFor="let cell of row"> {{cell.content}} 
      <span class ="dot" [ngClass]="{
        'dot-red' : cell.content == 'Busy',
        'dot-green' : cell.content == 'Idle',
        'dot-yellow' : cell.content == 'overload'}"></span></td>

.dot {
  height: 20px;
  width: 20px;
  border-radius: 50%;
  display: inline-block;
}
.dot-red {
  background-color: red;
}
.dot-green {
  background-color: green;
}
.dot-yellow {
  background-color: yellow;
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54740957

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档