У меня есть json, который содержит имя столбца 'status', имеющее несколько значений через запятую. Я уже заполнил этот json в мою таблицу, но здесь проблема в том, что мне нужно поместить тот же цвет фона, что и из json в span. Я не понимаю, как это сделать. Может кто-нибудь, пожалуйста, помогите мне в этом. Вот код ниже
home.component. html
<div>
<table>
<tr *ngFor="let x of statusdata1;">
<td style="border:1px solid"><span>{{x.vehicle_number}}</span></td>
<td style="border:1px solid"><span style="background:{{x.status}}">{{x.status}}</span></td>
</tr>
</table>
</div>
home.component.ts
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {
imageSource :any;
statusdata1: any;
constructor() {}
ngOnInit() {
this.statusdata1 = [{"vehicle_number":1,"status":"red,green"},{"vehicle_number":2,"status":"yellow,red"}];
console.log(this.statusdata1);
}
}