【发布时间】:2020-12-23 23:30:14
【问题描述】:
我有 MyObject.ts 文件
name:String
rowStyle:String
和 MyComponent.ts 文件为
myObject1:MyObject=new MyObject();
myObject2:MyObject=new MyObject();
myObjectList:MyObject[]=[];
myObject1.name="Red Color Row"
myObject1.rowStyle="background-color:red"
myObject2.name="Bold Font"
myObject2.rowStyle="font-weight:bold"
myObjectList.push(myObject1);
myObjectList.push(myObject2);
和 MyComponent.html 文件为
<p-table [value]="myObjectList">
<ng-template pTemplate="header">
<tr>
<th>Name</th>
<th>Styles</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-listObject>
<tr>
<td>listObject.name</td>
<td>listObject.rowStyle</td>
</tr>
</ng-template>
</p-table>
现在如何将 rowStyle 属性中指定的样式应用于表格的行?
【问题讨论】:
-
试试这个
<tr [style]="listObject.rowStyle">
标签: angular typescript primeng