Cuando uso este código de la documentación, funciona en el módulo raíz, pero quiero hacer lo mismo en el módulo con carga diferida. Cuando intento reordenar la tabla en un módulo con carga diferida, se congela. Revisé la importación y todo está bien, así que si alguien tuvo el mismo problema, por favor ayuda :).
HTML
<p-table [value]="products" [columns]="cols" [reorderableColumns]="true" responsiveLayout="scroll"> <ng-template pTemplate="header" let-columns> <tr> <th style="width:3rem"></th> <th *ngFor="let col of columns" pReorderableColumn> {{col.header}} </th> </tr> </ng-template> <ng-template pTemplate="body" let-rowData let-columns="columns" let-index="rowIndex"> <tr [pReorderableRow]="index"> <td> <span class="pi pi-bars" pReorderableRowHandle></span> </td> <td *ngFor="let col of columns"> {{rowData[col.field]}} </td> </tr> </ng-template> </p-table>TS:
import { Component, OnInit } from '@angular/core'; import { Product } from '../../domain/product'; import { ProductService } from '../../service/productservice'; @Component({ templateUrl: './tablereorderdemo.html' }) export class TableReorderDemo implements OnInit { products: Product[]; cols: any[]; constructor(private productService: ProductService) { } ngOnInit() { this.productService.getProductsSmall().then(data => this.products = data); this.cols = [ { field: 'code', header: 'Code' }, { field: 'name', header: 'Name' }, { field: 'category', header: 'Category' }, { field: 'quantity', header: 'Quantity' } ]; } }