可以使用以下代码示例来实现:
<p-table [value]="data" [frozenWidth]="'200px'" [scrollable]="true" scrollHeight="500px" [scrollDirection]="'both'">
<ng-template pTemplate="header">
<th class="frozen-column" [style.text-align]="'right'">Frozen Column</th>
<th>Other Column 1</th>
<th>Other Column 2</th>
<th>Other Column 3</th>
<th>Other Column 4</th>
<th>Other Column 5</th>
</ng-template>
<ng-template pTemplate="body" let-rowData let-rowIndex="rowIndex">
<td class="frozen-column" [style.text-align]="'right'">{{rowData.col1}}</td>
<td>{{rowData.col2}}</td>
<td>{{rowData.col3}}</td>
<td>{{rowData.col4}}</td>
<td>{{rowData.col5}}</td>
<td>{{rowData.col6}}</td>
</ng-template>
</p-table>
在上述代码中,我们使用了p-table指令来创建primeng表格。我们设置了value属性来绑定数据,并使用了[frozenWidth]属性来设置固定列的宽度。我们同时设置了[scrollable]属性和[scrollDirection]属性来实现双向滚动。我们使用了[style.text-align]属性来将固定列向右对齐。
请注意,我们在固定列的单元格中添加了一个类名“frozen-column”。在这个类名上应用CSS样式来使这些列始终保持固定的位置。