angular - PrimeNG 使用数组对象排序
问题描述
我想知道是否可以使用对象数组将某些内容排序到表中?
我正在使用 Angular 11 和 PrimeNG 11.0.0-rc.1
this.cols = [
{ field: 'day', header: 'Jour' },
{ field: 'class', header: 'Classe', type: "object", subField: 'classId'}
];
<ng-template pTemplate="header" let-columns>
<tr>
<th *ngFor="let col of columns" [pSortableColumn]="col.hasOwnProperty('subField') ? col.subField : col.field">
{{col.header}}
<p-sortIcon [field]="col.hasOwnProperty('subField') ? col.subField : col.field"></p-sortIcon>
</th>
<th *ngIf="!isStudent && !isTeacher" style="width:5rem"></th>
</tr>
<tr>
<th *ngFor="let col of columns">
<p-columnFilter type="text" [field]="col.hasOwnProperty('subField') ? col.subField : col.field" display="menu"></p-columnFilter>
</th>
<th *ngIf="!isStudent && !isTeacher"></th>
</tr>
</ng-template>
我尝试使用上面的代码,但它不起作用
解决方案
推荐阅读
- javascript - 引用对象的变量 id 和使用“this”有什么区别吗?
- javascript - 函数构造函数与 eval
- python - 字符串到 Tensorflow 中的 one_hot 张量
- c++ - C++ 为什么我的递归函数在我融合循环时表现不同?
- java - Spring Annotation 缺少 requestBody
- mysql - MYSQL 错误 1054 (42S22):“where 子句”中的未知列
- javascript - 如何使用 ctx.drawImage 将数组中的随机图像推送到画布上?
- c++ - char[] 和 int[] 的区别
- android - RxJava - 摆脱blockingGet(),但等待返回语句直到调用onComplete
- android - 如何使用 list-index-string 中的 findViewById() 。findViewById(R.id."List.get(indexnumber)")?