我有这个表=> click
<table class="table table-bordered" *ngFor="let list of lists">
<caption>{{ list.nodename }}</caption>
<thead>
<tr>
<th>Название сервиса</th>
<th>Статус</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let service_rec of list.servicelist">
<td>{{ service_rec.name }}</td>
<td>{{ service_rec.status }}</td>
</tr>
</tbody>
</table>
我设置颜色的任务 - green = online
,red = offline
,但我不知道怎么做! :(帮助,PLZ。
我在这个json上获得数据
ngOnInit(){
this._service.getServices()
.subscribe(lists => this.lists = lists)
}
和这个
getServices(){
return this._http.get(this._url)
.map(res => res.json());
}
答案 0 :(得分:1)
你的问题不是很清楚,但我认为你想要的东西是这样的。
<tr *ngFor="let service_rec of list.servicelist" >
<td>{{ service_rec.name }}</td>
<td [style.background-color]="service_rec.status == 'Online' ? 'green' : 'red'">{{ service_rec.status }}</td>
</tr>